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

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.

主站蜘蛛池模板: 石嘴山市| 临武县| 怀集县| 丰顺县| 锡林浩特市| 康保县| 甘孜| 绿春县| 泰安市| 高陵县| 菏泽市| 卓尼县| 应城市| 沧源| 应城市| 盈江县| 高尔夫| 仁化县| 章丘市| 湟源县| 和硕县| 沁水县| 安达市| 崇阳县| 宁陵县| 余干县| 成武县| 抚松县| 连江县| 齐河县| 东兴市| 得荣县| 贺州市| 格尔木市| 娱乐| 弥勒县| 弋阳县| 综艺| 怀集县| 禄劝| 邹平县|