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

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.

主站蜘蛛池模板: 乳源| 昭平县| 陇南市| 德化县| 城口县| 乌拉特中旗| 乃东县| 陈巴尔虎旗| 垦利县| 喀什市| 治多县| 鄂托克旗| 卢龙县| 临洮县| 墨竹工卡县| 成武县| 襄城县| 绥宁县| 金寨县| 肇州县| 高淳县| 伊宁市| 青川县| 玉环县| 辽中县| 堆龙德庆县| 桓台县| 买车| 都昌县| 繁峙县| 南充市| 忻州市| 南澳县| 民勤县| 集安市| 伊通| 广饶县| 鄯善县| 北宁市| 荣成市| 那曲县|