Swift 三 字符串 Strings

140 阅读1分钟
let someString = "Some string literal value"
let quotation = """
The White Rabbit put on his spectacles.  "Where shall I begin,
please your Majesty?" he asked.

"Begin at the beginning," the King said gravely, "and go on
till you come to the end; then stop."
"""
let threeMoreDoubleQuotationMarks = #"""
Here are three more double quotes: """
"""#
// Here are three more double quotes: """
  • 初始化空字符串
var emptyString = ""
var anotherEmptyString = String()

if emptyString.isEmpty {
    print("空字符串")
}
  • 字符
for character in "Dog!🐶" {
    print(character)
}
/*
 D
 o
 g
 !
 🐶
 */