官术网_书友最值得收藏!

Type annotation

In Swift, it is possible to annotate types, or in other words, explicitly specify the type of a variable or expression. Let's look at the following example:

let pi: Double = 3.14159 
let piAndPhi: (Double, Double) = (3.14159, 1.618)
func ourFunction(a: Int) { /* ... */ }

In this example, we define a constant (pi) annotated as Double, a tuple named piAndPhi annotated as (Double, Double), and a parameter of ourFunction as Int.

主站蜘蛛池模板: 赫章县| 仁布县| 苍溪县| 大英县| 安多县| 辛集市| 曲阳县| 安康市| 亳州市| 柘荣县| 常山县| 长治县| 安多县| 宝应县| 甘洛县| 邓州市| 西乌| 武功县| 和林格尔县| 本溪| 台中县| 鄂托克旗| 九台市| 壶关县| 清流县| 湛江市| 和林格尔县| 阿瓦提县| 如皋市| 定州市| 射洪县| 通州市| 会同县| 阜新市| 麻江县| 汉沽区| 吉安县| 泸西县| 兴和县| 十堰市| 青川县|