美文网首页
swift5.0 结构体

swift5.0 结构体

作者: marlonxlj | 来源:发表于2021-07-15 11:22 被阅读0次
    struct Student
    {
        var name = "unknow"
        var age = 0
        var score = 0.0
        var isPass = false
    
        static let schollName = "雷迪森"
        
        init(name:String,age:Int,score:Double) {
            self.name = name
            self.age = age
            self.score = score
            
            if self.score < 60 {
                self.isPass = false
            }else{
                self.isPass = true
            }
        }
        
        func fetch() -> String
        {
            return self.name
            
        }
    }
    
    var a = Student(name: "嘻嘻嘻", age: 20, score: 90)
    
    print(a)
    print(Student.schollName)
    
    

    相关文章

      网友评论

          本文标题:swift5.0 结构体

          本文链接:https://www.haomeiwen.com/subject/ssmppltx.html