Enumeration

1、当一个枚举值类型已经确定后,可以使用shorter dot syntax来赋予其它值:

  

2、对一个枚举值switch的时候也可以使用short dot syntax:

  

3、Associate Value 定义:

  

  

  

  上面extract的值均为const,把let改为var可以extract出变量。

4、定义RawValue:

  

  

  作用toRaw获取raw-value:

  

Classes & Structures

1、生成实例,直接类型名+(),无需使用new:

  

2、带构造函数的初始化:

  

3、Structures & Enumerations are Value-Types

4、Classes are Reference-Type。

5、使用===与!==来判断两个对象是否引用了同一个实例。

  

6、Identical 与 Equal:

  

7、Array、Dictionary是structure类型,也即是value-type。

  当赋值dictionary的时候,会进行copy:

  

  

  当赋值array的时候,会进行reference:

  

  

8、当array使用append等改变array长度操作的时候,会产生一个新的array:

  

9、array的unshare方法可以产生一个拷贝:

  

  

10、使用...来判断两个array中的元素是否相同:

  

11、使用copy方法强制拷贝:

  

  

Enumeration & Class & Structure的更多相关文章

  1. C#编程利器之二:结构与枚举(Structure and enumeration)【转】

    C#编程利器之二:结构与枚举(Structure and enumeration) 在上一篇文章中,介绍了类如何封装程序中的对象.而实际中,出了类可以封装对象外,结构和枚举也可以封装一些对象,本文将着 ...

  2. Plain old data structure(POD)

    Plain old data structure, 缩写为POD, 是C++语言的标准中定义的一类数据结构,POD适用于需要明确的数据底层操作的系统中.POD通常被用在系统的边界处,即指不同系统之间只 ...

  3. Fast Enumeration

    在 Objective-C 2.0 中提供了快速枚举的语法,它是我们遍历集合元素的首选方法.它具有以下优点: 比直接使用 NSEnumerator 更高效: 语法非常简洁: 如果集合在遍历的过程中被修 ...

  4. [LeetCode] All O`one Data Structure 全O(1)的数据结构

    Implement a data structure supporting the following operations: Inc(Key) - Inserts a new key with va ...

  5. [LeetCode] Add and Search Word - Data structure design 添加和查找单词-数据结构设计

    Design a data structure that supports the following two operations: void addWord(word) bool search(w ...

  6. [LeetCode] Two Sum III - Data structure design 两数之和之三 - 数据结构设计

    Design and implement a TwoSum class. It should support the following operations:add and find. add - ...

  7. [转]使用Enumeration和Iterator遍历集合类

    原文地址:http://www.cnblogs.com/xwdreamer/archive/2012/05/30/2526268.html 前言 在数据库连接池分析的代码实例中,看到其中使用Enume ...

  8. Theano Graph Structure

    Graph Structure Graph Definition theano's symbolic mathematical computation, which is composed of: A ...

  9. 修复 OS X 的系统盘出现 Invalid Node Structure 问题

    昨晚我的MBP突然出现启动的时候会自动关机的问题.开机进入到 Recovery 模式之后,用 Disk Utility 检查系统盘,发现 Invalid Node Structure 错误, Disk ...

随机推荐

  1. dojo chart生成函数

    写了一个函数,就是通过传递参数,生成图表,代码如下: /** * created by LZUGIS * @param container * @param type * @param data * ...

  2. Proposition

    提供 \(k\) 个变量 \((k\leq 4)\) 可独立取值为 \(0,1\),两种运算分别等价于 \(\neg a\) 和 \(\neg a \lor b\) . 你需要恰好使用 \(n\) 个 ...

  3. C++之内存管理

    内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中获得了更好的性能,更大的自由,C++菜鸟的收获则是一遍一遍的检查代码和对C++的痛恨,但内存管理在C++中无处不在,内存泄 ...

  4. Rhel7安装及网卡、yum、vmtools配置和修改主机名

    (1)安装Vmware WorkStation 11.0 和 RetHatEnterpriseLinux[RHEL]7.0 步骤就不描述了,网上都可以找到 (2)安装VMware Tools )虚拟机 ...

  5. map/reduce类简单介绍

    在Hadoop的mapper类中,有4个主要的函数,分别是:setup,clearup,map,run.代码如下: protected void setup(Context context) thro ...

  6. 十八、python沉淀之路--生成器

    一.生成器 生成器总结:语法上和函数类似:生成器函数和常规函数几乎是一样的.他们都是使用def语句进行定义,差别在于生成器使用yield语句返回一个值,而常规函数使用return语句返回一个值.自动实 ...

  7. (转)setTextColor()的参数设置方式

    setTextColor()的参数设置方式 分类: Android界面研究2011-12-09 23:27 11160人阅读 评论(2) 收藏 举报 查了下资料发现setTextColor()的参数应 ...

  8. 加载rocksdb实例报错:java.lang.UnsatisfiedLinkError: C:\Users\Administrator\AppData\Local\Temp\librocksdbjni3696928169151614297.dll

    项目的缓存中用到了rocksdb,实例化时报错了: Related cause: org.springframework.beans.factory.BeanCreationException: Er ...

  9. 有关Botton的用法(二)

    关于设置listener监听onClicked事件的步骤分析 Steps: 1.tell android you are interested in listening to a button cli ...

  10. VM 修改 virtualHW.version

    1.修改BT5R3-GNOME-VM-32.vmdk文件 将encoding="windows-1252"修改为encoding="GBK" 将ddb.virt ...