Int vs Integer in Swift

前端 未结 1 1779
独厮守ぢ
独厮守ぢ 2021-02-18 15:38

Does anyone know what the difference is between these two types?

The docs only refer to Int but Xcode 6 auto complete only gives me Integer whe

相关标签:
1条回答
  • 2021-02-18 15:56

    An Int is the type whilst an Integer is a protocol it implements.

    You should be using Int in declarations, i.e:

    var num: Int = 5
    

    which is also the type that's inferred for integer literals when a type isn't specified, i.e:

    var num = 5
    
    0 讨论(0)
提交回复
热议问题