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

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" 
主站蜘蛛池模板: 依安县| 扎兰屯市| 浦县| 阳东县| 田阳县| 扶沟县| 长治县| 普兰县| 临沭县| 花莲市| 分宜县| 娱乐| 玛纳斯县| 武穴市| 河西区| 东方市| 微博| 安达市| 汶上县| 禹州市| 黄陵县| 旬阳县| 视频| 张掖市| 彭水| 正蓝旗| 新巴尔虎右旗| 大姚县| 新竹市| 贵南县| 宜宾县| 东山县| 岱山县| 喀喇| 衡阳县| 漳州市| 三门峡市| 松阳县| 西乡县| 金坛市| 通城县|