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

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.

主站蜘蛛池模板: 玛沁县| 宁波市| 黄梅县| 宝应县| 嘉黎县| 新宾| 汶川县| 嘉鱼县| 常州市| 丁青县| 蚌埠市| 理塘县| 钦州市| 略阳县| 佛坪县| 兴文县| 湟源县| 城步| 朝阳县| 澄迈县| 马边| 黄石市| 乌拉特后旗| 博野县| 宜兴市| 西林县| 靖西县| 南溪县| 卫辉市| 长宁县| 丰台区| 礼泉县| 米易县| 莆田市| 澄城县| 林州市| 耿马| 石棉县| 烟台市| 庆云县| 长丰县|