[swift-users] Strange Error about Default values

Adrian Zubarev adrian.zubarev at devandartist.com
Wed Jan 18 09:29:49 CST 2017


Computed properties do not have any default values. That said, you can only use didSet or willSet on properties like yours to observe them or remove the default value from the computed property completely to use get and set.



-- 
Adrian Zubarev
Sent with Airmail

Am 18. Januar 2017 um 15:06:16, Wang LiMing via swift-users (swift-users at swift.org) schrieb:

In latest Xcode(8.2.1), playground

struct S1 {
  var v = 1 {
    get {                   // report Error: Use of unresolved identifier ‘get'
      return self.v.    // report Error: Use of unresolved identifier ‘self'
   }
}

I can’t found the reason about the error.
_______________________________________________
swift-users mailing list
swift-users at swift.org
https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170118/a983bb6f/attachment.html>


More information about the swift-users mailing list