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

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.

主站蜘蛛池模板: 白水县| 温宿县| 徐水县| 宁强县| 农安县| 淳化县| 资阳市| 井研县| 若羌县| 大同县| 乌海市| 南召县| 远安县| 德安县| 承德市| 琼结县| 华安县| 巴南区| 诏安县| 龙岩市| 丽江市| 田阳县| 翁牛特旗| 板桥市| 岐山县| 东乌| 天祝| 嘉义县| 巫山县| 津南区| 中阳县| 确山县| 新晃| 长治市| 内丘县| 贵溪市| 灵石县| 肇源县| 林甸县| 苏州市| 屯门区|