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

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.

主站蜘蛛池模板: 屯门区| 贵定县| 依兰县| 佳木斯市| 漠河县| 花垣县| 宝山区| 崇州市| 广丰县| 香港 | 金川县| 尼木县| 蕲春县| 同德县| 宁津县| 佛坪县| 五河县| 天门市| 灵山县| 鞍山市| 金沙县| 突泉县| 牙克石市| 乌海市| 邯郸市| 镇赉县| 沿河| 肥西县| 宁波市| 宝丰县| 万载县| 临沂市| 五河县| 黔东| 华容县| 德兴市| 扬中市| 襄垣县| 新和县| 灌阳县| 蚌埠市|