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

Type inference

Swift provides type inference. Swift infers the type of a variable, constant, or expression automatically, so we do not need to specify the types while defining them. Let's look at the following example:

let pi = 3.14159 
var primeNumber = 691
let name = "my name"

In this example, Swift infers pi as Double, primeNumber as Int, and name as String. If we need special types such as Int64, we will need to annotate the type.

主站蜘蛛池模板: 哈密市| 贡觉县| 昭觉县| 蒙山县| 开江县| 云阳县| 息烽县| 青冈县| 磐安县| 闸北区| 安龙县| 湘潭县| 赤壁市| 密山市| 富川| 纳雍县| 民县| 内乡县| 静宁县| 汝州市| 会泽县| 台安县| 通化市| 兴宁市| 昭苏县| 望都县| 临泉县| 大足县| 革吉县| 高平市| 宜宾县| 玉树县| 土默特左旗| 合作市| 河曲县| 永安市| 桃江县| 辽阳县| 商丘市| 宁安市| 泽州县|