swift - Why does SwiftyJSON create implicitly unwrapped optional for its constants? -
in swiftlyjson's code, defines following constants using forced unwrapping:
///error code public let errorunsupportedtype: int! = 999 public let errorindexoutofbounds: int! = 900 public let errorwrongtype: int! = 901 public let errornotexist: int! = 500
what's purpose of declaring constants implicitly unwrapped optional here?
note: not asking why or when use implicitly unwrapped, rather why it's used in swiftyjson see no reason that.
well, maybe i'm wrong, of course better way ask author of code. here suggestions anyway:
- by blaming commit can see changes made @ oct 6 2014 , know swift released there compiler warnings or maybe errors:
actually writing
int!
instead ofint
forcing compiler generateimplicitlyunwrappedoptional<int>
type (and knowing fact return item 1):public let x: int = 1 public let y: int! = 2 println(x.dynamictype) println(y.dynamictype)
outputs:
swift.int swift.implicitlyunwrappedoptional<swift.int>
Comments
Post a Comment