【问题标题】:long long constant number in swiftswift中的long long常量
【发布时间】:2016-08-26 11:18:35
【问题描述】:

我正在寻找 Objective-C 常量 long long intfloat 数字的 Swift 别名。

也就是说,1000LL.1f 怎么转换成 Swift 代码?

这里没有找到信息:

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html

【问题讨论】:

    标签: swift


    【解决方案1】:

    当您需要在 Swift 中指定文字类型时,您可以使用 as-casting。

    1000LL -> 1000 as Int64

    .1f -> 0.1 as Float

    【讨论】:

    • 还有:Int64(1000)let i: Int64 = 1000——任何允许编译器推断类型的东西。
    猜你喜欢
    • 2015-10-18
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-29
    • 1970-01-01
    相关资源
    最近更新 更多