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. Flask的简单认识

    Flask的简单认识 Flask是轻量级的框架,适用于简单的程序 与Django的比较: Django: 无socket,中间件,路由,视图(CBV,FBV),模板,ORM, cookie,sessi ...

  2. Every derived table must have its own alias

    完整错误信息如下: Every derived table must have its own alias 三月 28, 2017 10:20:46 上午 org.apache.catalina.co ...

  3. android线程 Handler Message Queue AsyncTask线程模型 线程交互 + 修改Button样式 示例 最终easy整合版

     首先原谅我把文章的标题写的这么长.其实我还嫌弃它短了因为 写不下去了所以我就不写了.因为我实在不知道该怎么定义这篇文章的标题或许应该叫 "乱谈"比较合适. 这样可能还体现了 ...

  4. 限流之令牌桶算法——RateLimiter官方文档

    原文链接 作者:Dimitris Andreou  译者:魏嘉鹏 校对:方腾飞 RateLimiter 从概念上来讲,速率限制器会在可配置的速率下分配许可证.如果必要的话,每个acquire() 会阻 ...

  5. display:box属性

    在移动端开发的时候,圣杯布局,弹性盒,是我们经常会用得到的,W3C很久以前就有一个display:box属性 flex是最新的,但是在实际的浏览器测试中,display: flex 不能完全替代dis ...

  6. linux基础【文件夹含义】

    linux文件目录是一个树状的目录 bin -->可执行文件 boot-->操作系统引导文件,系统内核,启动信息 dev -->device,设备信息,计算机硬件设备信息 etc - ...

  7. cocos2d-x3.16 default模式项目 Android Studio C++文件编译失败问题

    gradle sync正常,但是在编译的时候几乎自己写的Classes里全部c++文件的最后一行都在报错,原来是3.16 模板cpp-template-default内的Android.mk文件内这一 ...

  8. tensorflow中常用激活函数和损失函数

    激活函数 各激活函数曲线对比 常用激活函数: tf.sigmoid() tf.tanh() tf.nn.relu() tf.nn.softplus() tf.nn.softmax() tf.nn.dr ...

  9. Php header()函数及其常见使用

    语法: Void header(string $string[,bool $replace=true [, int $http_response_code) 向客户端发送原始的HTTP报头 需注意: ...

  10. 中间件——Oracle Fusion Middleware

    Oracle Fusion Middleware定义: 什么是Oracle Fusion Middleware Oracle Fusion Middleware is a comprehensive ...