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. 在 Ubuntu 上搭建 Hadoop 分布式集群 Eclipse 开发环境

    一直在忙Android FrameWork,终于闲了一点,利用空余时间研究了一下Hadoop,并且在自己和同事的电脑上搭建了分布式集群,现在更新一下blog,分享自己的成果. 一 .环境 1.操作系统 ...

  2. Android的方法和属性(2)

    1.RadioButton(单选按钮) 嵌入到RsdioGroup中实现单选效果 android:checkedButton="radio的id值" int getCheckedR ...

  3. Python正则表达式使用过程中的小细节

    今天用Python写了个简单的爬虫程序,抓取虎扑篮球(nba.hupu.com)的首页内容,代码如下: #coding:gb2312 import urllib2, re webpage = urll ...

  4. warning MSB8004: Output Directory does not end with a trailing slash.

    当在VC里编译时,发现这个警告,就是说设置的目录参数不是以反斜杠结束的目录名称,如下: 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V ...

  5. HTTrack - 克隆任意网站

    HTTrack可以克隆指定网站-把整个网站下载到本地. 可以用在离线浏览上,也可以用来收集信息(甚至有网站使用隐藏的密码文件). 一些仿真度极高的伪网站(为了骗取用户密码),也是使用类似工具做的. K ...

  6. myeclipse三个地方的java版本统一

    1 java build path 2 java compiler 3 Myeclipse -> project facets

  7. HDU2032 杨辉三角

    解题思路:不要小看这题水题,如果数据类型没有用long long, 当n开为35时,会出现TLE,而且会报非法内存访问,现在还 不理解为什么,若有高手,请不吝赐教. 上代码: #include< ...

  8. C# 浅拷贝与深拷贝(复制)

    在有些时候,我们需要从数据库读取数据填充对象或从硬盘读取文件填充对象,但是这样做相对耗时.这时候我们就想到了对象的拷贝.本文即以实例形式解析了C#浅拷贝和深拷贝的用法. C#中有两种类型变量,一种 是 ...

  9. SqlServer2008 新建服务器对象->链接服务器脚本

    exec sp_addlinkedserver   'ddxx', '', 'SQLOLEDB','1.192.168.220'exec sp_addlinkedsrvlogin 'ddxx','fa ...

  10. imageView添加阴影和边框

    注意:大量设置阴影会造成卡顿!!! 用上这句之后流畅度大大增加:imageV.layer.shouldRasterize = YES; 例: // 设置阴影 imageV.layer.shadowOf ...