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. iphone5s越狱之后必装

    一.iphone5s完美越狱之后必装插件一览表 由于iPhone5s配置了强大的64位的A7处理器,所以在iOS7完美越狱后,不少iPhone5s用户发现之前安装的大部分人们插件在越狱后难以兼容.但是 ...

  2. 嵌入式中 ARM的几种工作模式 以及异常模式的优先级

    一.Arm工作模式: Arm微处理器支持7种工作模式,分别为: 1. 用户模式(Usr)            用于正常执行程序 2. 快速中断模式(FIQ)    用于高速数据传输 3. 外部中断模 ...

  3. Ganymed实现基本的自动化部署API

    Ganymed SSH-2 for Java是一个纯Java实现的SHH2库,官网为http://www.ganymed.ethz.ch/ssh2/,最新的更新时间为2006年10月,在用之前,请仔细 ...

  4. Win7系统64位环境下使用Apache——Apache2.4整合Tomcat与mod_jk

    转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/70398091 本文出自[我是干勾鱼的博客] 之前的几篇文章: Win7系统64位 ...

  5. c++ 字符串查找函数

    头文件:#include <string.h> 定义函数:int strcasecmp (const char *s1, const char *s2); 函数说明:strcasecmp( ...

  6. [QT][SQLITE][QTDEMO]qt5.8_sqlite数据库_demo

    qt环境:5.8 数据库:sqlite //-------------------------------------- sqlite 日期 搜索 -------------------------- ...

  7. 在spring配置文件中的 <context:property-placeholder/>用途

    location属性为 具体配置文件的classpath:地址 (可以取配置文件中的值利用${key}的形式,而不用多次写值) 1.这样一来就可以为spring配置的bean的属性设置值了,比如spr ...

  8. HelloWorld 模块

    helloworld.c 代码 #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("D ...

  9. HihoCoder1622 : 有趣的子区间(预处理+组合数)

    有趣的子区间 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 如果一个区间[a, b]内恰好包含偶数个回文整数,我们就称[a, b]是有趣的区间. 例如[9, 12]包含 ...

  10. 51nod 2006 飞行员配对

    第二次世界大战时期,英国皇家空军从沦陷国征募了大量外籍飞行员.由皇家空军派出的每一架飞机都需要配备在航行技能和语言上能互相配合的2名飞行员,其中1名是英国飞行员,另1名是外籍飞行员.在众多的飞行员中, ...