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

Type safety and type inference

Swift has a strong emphasis on types. Classes, enums, structs, protocols, functions, and closures can become types and be used in program composition.

Swift is a type-safe language, unlike languages such as Ruby and JavaScript. As opposed to type-variant collections in Objective-C, Swift provides type-safe collections. Swift automatically deducts types by the type-inference mechanism, a mechanism that is present in languages such as C# and C++ 11. For instance, constString in the following example is inferred as String during compile time, and it is not necessary to annotate the type:

let constString = "This is a string constant" 
主站蜘蛛池模板: 喀喇沁旗| 来宾市| 汽车| 巴青县| 南丰县| 新营市| 益阳市| 扬州市| 土默特左旗| 阳曲县| 兴安县| 手机| 温州市| 云阳县| 邯郸县| 上虞市| 邵武市| 武穴市| 江油市| 炎陵县| 信丰县| 新蔡县| 孙吴县| 海原县| 山阴县| 太保市| 阳春市| 五指山市| 那曲县| 云浮市| 宁夏| 西乌珠穆沁旗| 铁岭县| 三穗县| 遂川县| 大宁县| 集贤县| 武宣县| 呼伦贝尔市| 石家庄市| 滦南县|