Enumeration

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

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

3、Associate Value 定义:

  Enumeration & Class & Structure

  Enumeration & Class & Structure

  Enumeration & Class & Structure

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

4、定义RawValue:

  Enumeration & Class & Structure

  Enumeration & Class & Structure

  作用toRaw获取raw-value:

  Enumeration & Class & Structure

Classes & Structures

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

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

3、Structures & Enumerations are Value-Types

4、Classes are Reference-Type。

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

  Enumeration & Class & Structure

6、Identical 与 Equal:

  Enumeration & Class & Structure

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

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

  Enumeration & Class & Structure

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

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

  Enumeration & Class & Structure

  

 

相关文章:

  • 2021-05-24
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2021-04-23
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2021-09-13
  • 2021-07-20
  • 2021-08-28
  • 2021-12-12
相关资源
相似解决方案