如何使用类型注释
var name: String = "John"
var score: Double = 0
var albums: [String] = ["Red", "Fearless"]
var user: [String: String] = ["id": "@twostraws"]
var books: Set<String> = Set(["The Bluest Eye", "Foundation", "Girl, Woman, Other"])
//赋予空值
var cities: [String] = []
var clues = [String]()
下面初始化是否合法?
let username: String
// lots of complex logic
username = "@twostraws"
// lots more complex logic
print(username)
网友评论