//: Playground - noun: a place where people can play
importCocoa
varstr ="Hello,playground"
classPerson {
age:Int;//类成员变量默认是public
name:String?;//?表示可以为nil或没有设置,name是可选的
init(age:Int,name:String){
self.age= age;
name= name;
}
funcgetAge()->Int{
returnage;
}
funcgetName()->String{
returnname!;//!表示可以返回nil
}
classfuncperson()->Person{
Person(age:30,name:"Xuhuiz");
}
funcmaxAge()->return200;
}
}
varv1 =1,27)">"zxh");
println("\(v1.age),.name)");
varv2 =Person.maxAge();
varv3 =person();
v3.age=29;
println(v3.getAge());