swift - use backslash to add the value in the string
2016-03-08 14:46
447 查看
There’s an even simpler way to include values in strings: Write the value in parentheses, and write a backslash (
\) before the parentheses. This is known as string interpolation.
let apples = 3
let oranges = 5
let appleSummary = "I have \(apples) apples."
let fruitSummary = "I have \(apples + oranges) pieces of fruit."
相关文章推荐
- swift2.0 字符串,数组,字典学习代码
- Swift学习前言准备。
- Swift 实践之简单购物(UITableView的使用)
- swift 闭包
- 19.CoreMotion(陀螺仪)
- swift自制工厂模式
- 《从零开始学Swift》学习笔记(Day 65)——Cocoa Touch设计模式及应用之选择器
- 《从零开始学Swift》学习笔记(Day 64)——Cocoa Touch设计模式及应用之目标与动作
- 《从零开始学Swift》学习笔记(Day 63)——Cocoa Touch设计模式及应用之单例模式
- 《从零开始学Swift》学习笔记(Day 62)——Core Foundation框架之内存托管对象与非托管对象
- 《从零开始学Swift》学习笔记(Day 61)——Core Foundation框架之内存管理
- Swift中的willSet与didSet zhuan
- swift学习-元组
- OpenStack Swift 安装部署
- 01--swift之基本运算符
- 02--swift之字符串
- 03--swift之集合
- 04--swift之流程控制
- 05--swift之函数
- 06--swift之闭包