Basics

1、You can declare multiple constants or multiple variables on a single line, separated by commas:

  

2、You can use almost any character you like for constant and variable names, including Unicode characters:

  

  当声明一个变量后,你无法改变其类型,也无法从const发为非const。

3、注释可以多行嵌套:

  

4、Semicolons are required, however, if you want to write multiple separate statements on a single line:

  

5、通过min、max属性可以获得一个类型的最大最小值。

    

6、Int类型的数据范围随平台的不同而不同:

  

7、Numeric Literals

  

8、带指数的浮点数

  

  

9、Both integers and floats can be padded with extra zeroes and can contain underscores to help with readability.

   可以添加额外的前缀0,以及添加增可读性的_。

  

10、类型不同的Int不能直接相加,必须进行类型转换。

  

11、Floating-point values are always truncated when used to initialize a new integer value in this way. This means that 4.75 becomes 4, and -3.9 becomes -3.

  浮点数会被截断,即舍弃小数部分,直接返回整数部分。

12、typealias类型于C++中的typedef:

  

  

13、Tuple中的值可以分别为不同的类型。

  

  Tuple的内容也可被解放出来:

  

  也可只释放出tuple中的部分值:

  

  也可通过index来访问tuple中的内容:

  

  也可以给tuple中的每个元素命名:

  

  命名后可以通过名字来访问:

  

14、optional value可以在其名字后面加上!来直接引用其值,叫unwrapping。如果不加!,runtime会进行判空逻辑。

15、=号不返回值,即不可以写a=b=c。

  

16、两个Character类型相加会得到String类型。

  

17、%是remainder运算符,a%b与a%(-b)结果是一样的。

  

  %也可用在浮点数上:

  

18、unary plus operator (+)

  

19、 ===与!==用于判断两个reference是否引用同一个内存。

20、The closed range operator (a...b) defines a range that runs from a to b, and includes the values a and b.

   The half-closed range operator (a..b) defines a range that runs from a to b, but does not include b.

  

  

21、Swift’s String type is bridged seamlessly to Foundation’s NSString class.

22、You can find out whether a String value is empty by checking its Boolean isEmpty property:

  

23、Swift’s String type is a value type. If you create a new String value, that String value is copied when it is passed to a function or method, or when it is assigned to a constant or variable。

  To retrieve a count of the characters in a string, call the global countElements function and pass in a string as the function’s sole parameter:

  

  

Basics的更多相关文章

  1. Assembler : The Basics In Reversing

    Assembler : The Basics In Reversing Indeed: the basics!! This is all far from complete but covers ab ...

  2. The Basics of 3D Printing in 2015 - from someone with 16 WHOLE HOURS' experience

    全文转载自 Scott Hanselman的博文. I bought a 3D printer on Friday, specifically a Printrbot Simple Metal fro ...

  3. Cadence UVM基础视频介绍(UVM SV Basics)

    Cadence关于UVM的简单介绍,包括UVM的各个方面.有中文和英文两种版本. UVM SV Basics 1 – Introduction UVM SV Basics 2 – DUT Exampl ...

  4. C basics

    C 日记目录 C basics ................ writing Numeration storage   , structor space assigning pointer,  a ...

  5. Xperf Basics: Recording a Trace(转)

    http://randomascii.wordpress.com/2011/08/18/xperf-basics-recording-a-trace/   This post is obsolete ...

  6. Xperf Analysis Basics(转)

      FQ不易,转载 http://randomascii.wordpress.com/2011/08/23/xperf-analysis-basics/ I started writing a des ...

  7. Radio Basics for RFID

    Radio Basics for RFID The following is excerpted from Chapter 3: Radio Basics for UHF RFID from the ...

  8. 【IOS笔记】View Controller Basics

    View Controller Basics   视图控制器基础 Apps running on iOS–based devices have a limited amount of screen s ...

  9. NSInvocation Basics

    In this article I'm going to cover the basics and usages of NSInvocation. What is NSInvocation? Appl ...

  10. Qt 线程基础(Thread Basics的翻译,线程的五种使用情况)

    Qt 线程基础(QThread.QtConcurrent等) 转载自:http://blog.csdn.net/dbzhang800/article/details/6554104 昨晚看Qt的Man ...

随机推荐

  1. WebSocket 在烧瓶和龙卷风中的应用

    a. 安装 pip3 install gevent-websocket 作用: - 处理Http.Websocket协议的请求 -> socket - 封装Http.Websocket相关数据 ...

  2. javascript 继承的两种方式

    js中继承可以分为两种:对象冒充和原型链方式 一.对象冒充包括三种:临时属性方式.call()及apply()方式1.临时属性方式 代码如下: function Person(name){     t ...

  3. Java加载jar文件并调用jar文件当中有参数和返回值的方法

    在工作当中经常遇到反编译后的jar文件,并要传入参数了解其中的某些方法的输出,想到Java里面的反射可以实现加载jar文件并调用其中的方法来达到自己的目的.就写了个Demo代码. 以下的类可以编译生成 ...

  4. VSCode打开文件总是会覆盖上次打开的标签

    在使用VSCode的时候,打开一个文件之后,如果没有修改的话,那么再打开下一个文件的时候,他总会替换上次打开的标签,那么怎么样才能每次都在新的标签打开文件呢? 实际上,这种情况的出现是因为我们点击文件 ...

  5. opencv roi resize 会导致内存拷贝产生子图像

    opencv roi区域 resize之后,roi的引用已不是原图的引用,而是内存拷贝产生的子图像. http://blog.csdn.net/qianqing13579/article/detail ...

  6. vim 插件使用

    a.vim的安装相当简单,下载a.vim后丢进Vim插件目录(一般为~/.vim/plugin),必要时再重启一下Vim就可以使用了. 头/源文件切换命令 :A 头文件/源文件切换 :AS 分割窗后并 ...

  7. linux进程通信全面解析

      进程IPC 的 7种方式 linux下 进程通讯IPC的方式主要有以下7种: 1.文件 2.共享内存 3.信号 4.管道 5.套接字 6.消息列队 7.信号量   以下正文 中 一一 分析下: 1 ...

  8. Android 命令行模拟按键

    /***************************************************************************** * Android 命令行模拟按键 * 说 ...

  9. Python开发简单记事本

    摘要: 本文是使用Python,结合Tkinter开发简单记事本. 本文的操作环境:ubuntu,Python2.7,采用的是Pycharm进行代码编辑,个人很喜欢它的代码自动补齐功能. 最近很想对p ...

  10. Django之mysql表单操作

    在Django之ORM模型中总结过django下mysql表的创建操作,接下来总结mysql表记录操作,包括表记录的增.删.改.查. 1. 添加表记录 class UserInfo(models.Mo ...