swift 游乐园。写出实体类的扩展打印

import UIKit

var str = "Hello, playground"

func addTowNum(num1:Int,num2:Int) -> Int{
    return num1+num2;
}
let sum = addTowNum(num1: 100, num2: 150)
print(sum)
class Person{
    var name:String;
    var age:Int
    init(name:String,age:Int){
        self.name=name
        self.age=age
        
    }
}

extension Person:CustomStringConvertible{
    var description: String  {
        get{
            return "\(name),age \(age)"
        }
    }
    
}

let zhangsna=Person(name: "张三", age: 28)

swift 游乐园。写出实体类的扩展打印_第1张图片

你可能感兴趣的:(#,swift)