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:

  1. by blaming commit can see changes made @ oct 6 2014 , know swift released there compiler warnings or maybe errors:

enter image description here

  1. actually writing int! instead of int forcing compiler generate implicitlyunwrappedoptional<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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -