【问题标题】:Type annotation missing in pattern in swift 2.0swift 2.0 中模式中缺少类型注释
【发布时间】:2015-09-19 09:01:19
【问题描述】:

如下声明变量时出现错误“模式中缺少类型注释”:

var total

什么是类型注解?

【问题讨论】:

  • 编辑您的问题以正确显示错误

标签: ios swift swift2


【解决方案1】:

类型注解如下:

var total:Int

“:Int”是类型注解。当您在声明时未设置值(因此具有隐含类型)时,必须使用此选项。

如果您要如下定义变量:

var total = 9

您不再需要在声明时显式注释类型。

【讨论】:

    猜你喜欢
    • 2019-09-07
    • 1970-01-01
    • 2019-05-06
    • 2019-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-17
    相关资源
    最近更新 更多