Overriding a stored property in Swift

前端 未结 10 810
鱼传尺愫
鱼传尺愫 2020-11-30 00:10

I noticed that the compiler won\'t let me override a stored property with another stored value (which seems odd):

class Jedi {
    var lightSaberColor = \"Bl         


        
10条回答
  •  半阙折子戏
    2020-11-30 00:50

    class SomeClass {
        var hello = "hello"
    }
    class ChildClass: SomeClass {
        override var hello: String {
            set {
                super.hello = newValue
            }
            get {
                return super.hello
            }    
        }
    }
    

提交回复
热议问题