总结:swift中的枚举可以看作变量可以作为case匹配参数的类

Enumerations

枚举的作用:状态列举与匹配

枚举值与类型

If a value (known as a “raw” value) is provided for each enumeration case, the value can be a string, a character, or a value of any integer or floating-point type.

You can define a common set of related cases as part of one enumeration, each of which has a different set of values of appropriate types associated with it.

Enumerations in Swift are first-class types in their own right.

computed properties

instance methods

继承、协议

case

简化

match

.语法

swift语言点评八-枚举的更多相关文章

  1. Swift语言指南(八)--语言基础之元组

    原文:Swift语言指南(八)--语言基础之元组 元组 元组(Tuples)将多个值组合为一个复合值.元组内的值可以是任何类型,各个元素不需要为相同类型(各个元素之间类型独立,互不干扰--Joe.Hu ...

  2. swift语言点评十八-异常与错误

    1.错误类型与枚举的结合 enum VendingMachineError: Error { case invalidSelection case insufficientFunds(coinsNee ...

  3. swift语言点评一

    一.变量定义 1.常量与变量 Use let to make a constant and var to make a variable. 2.类型与推测 However, you don’t alw ...

  4. swift语言点评四-Closure

    总结:整个Closure的作用在于简化语言表述形式. 一.闭包的简化 Closure expression syntax has the following general form: { () -& ...

  5. swift语言点评二

    一.数据类型 1.基础类型的封装 Swift provides its own versions of all fundamental C and Objective-C types, includi ...

  6. swift语言点评十九-类型转化与检查

    1.oc比较: -(BOOL) isKindOfClass: classObj判断是否是这个类或者这个类的子类的实例 -(BOOL) isMemberOfClass: classObj 判断是否是这个 ...

  7. swift语言点评十七-Designated Initializers and Convenience Initializers

    Swift defines two kinds of initializers for class types to help ensure all stored properties receive ...

  8. swift语言点评十四-继承

    Overriding A subclass can provide its own custom implementation of an instance method, type method, ...

  9. swift语言点评十-Value and Reference Types

    结论:value是拷贝,Reference是引用 Value and Reference Types Types in Swift fall into one of two categories: f ...

随机推荐

  1. Hua Wei 机试题目一

    一.身份证号码验证 题目描述: 我国公民的身份证号码特点如下:1. 长度为18位:2. 第1-17位只能为数字:3. 第18位可以是数字或者小写英文字母x.4. 身份证号码的第7~14位表示持有人生日 ...

  2. js数组定义、属性及方法(push/pop/unshfit/shfit/reverse/sort/slice/splice/indexOf/lastIndexOf)

    数组 一.定义数组 * 字面量方式  var 数组名称 = [ value,value,... ] * 构造函数方式 var 数组名称 = new Array(value,value,...):  v ...

  3. C#实现软件监控外部程序运行状态的方法

    本文实例讲述了C#实现软件监控外部程序运行状态的方法.分享给大家供大家参考.具体方法如下: 需要外挂一个程序,用于监控另一个程序运行状态,一旦检测到另一程序关闭,就触发一个事件做其他处理. using ...

  4. 。net内存优化

    1.尽量减少和避免不必要的对象 2.优化算法和数据结构 3.采用非托管代码或者模块编写数据处理逻辑 4.NET应用程序的内存一定程度上受垃圾回收的影响.并指出,一些数据结构如List,系统会分配多余的 ...

  5. jtable的用法

    一.创建表格控件的各种方式:1)  调用无参构造函数.JTable table = new JTable();2)  以表头和表数据创建表格.Object[][] cellData = {{" ...

  6. Prototype-based programming

    Prototype-based programming is a style of object-oriented programming in which behaviour reuse (know ...

  7. J2EE概念汇总

    JVM 是Java Virtual Machine(Java虚拟机)的缩写,JVM是一种用于计算设备的规范,它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现的.Java虚拟 ...

  8. Pyhton学习——Day8

    ###########################################max函数#################################################### ...

  9. node——文件夹创建

    //创建文件夹 var fs=require('fs'); //1.异步 fs.mkdir("./第一个目录",function(err){ if (err) { return c ...

  10. .net基础总复习(3)

    第三天 2.单例模式 1)  将构造函数私有化 2)  提供一个静态方法,返回一个对象 3)  创建一个单例 3.XML 可扩展的标记语言 XML:存储数据 注意: XML严格区分大小写,并且成对出现 ...