1.struct,值类型,结构体会自动生成初始化方法,class是引用类型
struct Person { var name : String var age : Int func simpleDescription() -> String { return "name = \(name) , age = \(age)" } } let p = Person(name: "ly", age: 9) let k = p.simpleDescription() print(k)
时间: 2024-11-08 11:08:41