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

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" 
主站蜘蛛池模板: 盐源县| 达州市| 丹凤县| 龙海市| 洞头县| 辽阳市| 象山县| 宜兴市| 安平县| 泽库县| 临沂市| 长海县| 涞水县| 内江市| 许昌市| 抚顺市| 上犹县| 沾益县| 洛宁县| 从化市| 文安县| 成武县| 沙河市| 华蓥市| 和田市| 正镶白旗| 汕尾市| 舟曲县| 中阳县| 修水县| 名山县| 宣威市| 鹤庆县| 阿瓦提县| 北流市| 庄河市| 塘沽区| 化德县| 光泽县| 高安市| 竹山县|