在swift中声明变量

Bis*_*128 7 ios swift

我正在尝试按照教程说明如果我们不想在swift中初始化变量,我们可以执行以下操作;

var year:Integer
year = 2;
Run Code Online (Sandbox Code Playgroud)

但是,如果我声明上面的代码块,我会收到错误

"使用未声明的类型整数"

如果我使用以下代替它工作;

var year:integer_t
year = 2;
Run Code Online (Sandbox Code Playgroud)

为什么我需要这样做,但教程可以使用第一种方法?

谢谢

编辑:教程中的屏幕截图

在此输入图像描述

AlB*_*lue 18

您需要使用Int,而不是Integer.

var year:Int
year = 2
Run Code Online (Sandbox Code Playgroud)

注意:您可以在一行中执行此操作

var year:Int = 2
Run Code Online (Sandbox Code Playgroud)

并使用类型推断

var year = 2
Run Code Online (Sandbox Code Playgroud)

如果你有兴趣,我一直在写一些关于Swift的博客,从这里开始:

http://alblue.bandlem.com/2014/09/swift-introduction-to-the-repl.html

(您可以在http://alblue.bandlem.com/Tag/swift/订阅Feed )