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

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" 
主站蜘蛛池模板: 金山区| 昭平县| 屯留县| 富源县| 会宁县| 大庆市| 库伦旗| 安平县| 通州区| 威宁| 堆龙德庆县| 隆林| 贵定县| 团风县| 米泉市| 阿合奇县| 海城市| 秀山| 新兴县| 宜春市| 滦平县| 襄樊市| 轮台县| 铜陵市| 两当县| 蒙城县| 尼玛县| 朔州市| 黑山县| 环江| 新巴尔虎右旗| 华阴市| 崇礼县| 休宁县| 昌乐县| 镇坪县| 阜康市| 伊宁市| 五峰| 桦南县| 漳浦县|