In SwiftlyJSON's code, it defines the 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 the purpose of declaring constants as implicitly unwrapped optional here?
Note: I am not asking why or when to use implicitly unwrapped, but rather why it's used in SwiftyJSON as I see no reason for that.
Well, maybe I'm wrong, of course better way is to ask author of the code. But here is my suggestions anyway:
Actually by writing
Int!
instead ofInt
we are forcing compiler to generateImplicitlyUnwrappedOptional<Int>
type (and by knowing this fact we could return to item 1):Outputs: