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

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.

主站蜘蛛池模板: 新余市| 濮阳市| 项城市| 洞口县| 新平| 旌德县| 淳安县| 蒙城县| 黑山县| 平阳县| 鄂托克旗| 喀喇沁旗| 宣武区| 汉中市| 扎囊县| 四会市| 巧家县| 祁东县| 井陉县| 石阡县| 胶州市| 融水| 屏边| 呼伦贝尔市| 南陵县| 吐鲁番市| 东兰县| 左权县| 灵台县| 二连浩特市| 武功县| 乳山市| 高陵县| 宁都县| 邹城市| 五华县| 镶黄旗| 邵武市| 盖州市| 海伦市| 平舆县|