总结: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. http协议以及防盗链技术

    http协议,又称为超文本传输协议,顾名思义,http协议不仅能传输文本,还能传输图片,视频,压缩包等文件,http协议是建立在tcp/ip协议的基础之上的,http协议对php程序员来讲可以说是重中 ...

  2. 对ListView的Item子控件监听并跳转页面

    public class MyAdapteforOwner extends BaseAdapter{ List<OwnerDevice>datas; private Context con ...

  3. DB2load遇到SQL3508N错误

    SQL3508N装入或装入查询期间,当存取类型为 "<文件类型>" 的文件或路径时出错.原因码:"<原因码>".路径:"< ...

  4. ibatiS启动的异常 The content of elements must consist of well-formed character data or markup

    ibatiS启动的异常 The content of elements must consist of well-formed character data or markup 配置的动态SQL语句里 ...

  5. oracle常规操作

    dbms_job.broken(job1,true);

  6. Pyhton学习——Day4

    '''y=2*x+1x=3y->7x=3y->7'''# def test(x):# '''# 2*x+1# :param x:整形数字# :return: 返回计算结果# '''# y= ...

  7. selenim

    一.安装selenium Pip install selenium==2.53.1    (稳定版) 下载火狐浏览器35.0.1  http://dl.pconline.com.cn/download ...

  8. Android 7.0 Gallery图库源码分析3 - 数据加载及显示流程

    前面分析Gallery启动流程时,说了传给DataManager的data的key是AlbumSetPage.KEY_MEDIA_PATH,value值,是”/combo/{/local/all,/p ...

  9. 移动端和pc端,响应式设计布局

    1.什么是响应式 Web 设计? 响应式 Web 设计让你的网页能在所有设备上有好显示. 响应式 Web 设计只使用 HTML 和 CSS. 响应式 Web 设计不是一个程序或Javascript脚本 ...

  10. Settings Django Static Files

    静态文件是通过django.contrib.staticfiles来管理的. 配置Django静态文件,Djang官网静态文件配置介绍.简言之,通过以下三个步骤来配置和加载静态文件: 设置静态文件别名 ...