编辑代码



//定义一个类
class Student{
    var name:String = "lucy"
    var age:Int = 23
    
    func introduce() {
        print("My name is \(name),now \(age) years old.")
    }
}

//创建实例
var stu = Student()

print("\(stu.name) --> \(stu.age)")

stu.introduce()