码迷,mamicode.com
首页 > 编程语言 > 详细

swift - use backslash to add the value in the string

时间:2016-03-08 14:56:58      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

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.

  1. let apples = 3
  2. let oranges = 5
  3. let appleSummary = "I have \(apples) apples."
  4. let fruitSummary = "I have \(apples + oranges) pieces of fruit."

swift - use backslash to add the value in the string

标签:

原文地址:http://www.cnblogs.com/facial/p/5254033.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!