From 8cf7178bf8f76ce626ffd288b7c610cba98c6022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=8E=E4=BB=8A=E4=BB=A5=E5=90=8E?= <949478479@qq.com> Date: Sun, 6 Sep 2015 04:28:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E2=80=9C=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=B8=B8=E9=87=8F=E5=92=8C=E5=8F=98=E9=87=8F=E2=80=9D?= =?UTF-8?q?=20=E4=B8=AD=E2=80=9Cprint(=5F:separator:terminator:)=E2=80=9D?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 涉及到跳转链接 “默认参数值”,也在函数章节对应部分新加了链接。我参考别的链接照着弄的,不知道行不。。。- -! --- source/chapter2/01_The_Basics.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/source/chapter2/01_The_Basics.md b/source/chapter2/01_The_Basics.md index e834b49c..bbd0d086 100755 --- a/source/chapter2/01_The_Basics.md +++ b/source/chapter2/01_The_Basics.md @@ -149,23 +149,14 @@ languageName = "Swift++" ### 输出常量和变量 -你可以用`print(_:)`函数来输出当前常量或变量的值: +你可以用`print(_:separator:terminator:)`函数来输出当前常量或变量的值: ```swift print(friendlyWelcome) // 输出 "Bonjour!" ``` -`print(_:)`是一个用来输出的全局函数,输出的内容会在最后换行。如果你用 Xcode,`print(_:)`将会输出内容到“console”面板上。(另一种函数叫`print(_:appendNewline:)`,唯一区别是在输出内容最后不会换行。) - -`print(_:)`函数输出传入的`String`值: - -```swift -print("This is a string") -// 输出 "This is a string" -``` - -`print(_:)`函数可以输出更复杂的信息。这些信息可以包含当前常量和变量的值。 +`print(_:separator:terminator:)`是一个用来输出一个或多个值到适当输出区的全局函数。如果你用 Xcode,`print(_:separator:terminator:)`将会输出内容到“console”面板上。`separator`和`terminator`参数具有默认值,因此你调用这个函数的时候可以忽略它们。默认情况下,该函数通过添加换行符来结束当前行。如果不想换行,可以传递一个空字符串给`terminator`参数--例如,`print(someValue, terminator:"")`。关于参数默认值的更多信息,请参考[默认参数值](./06_Functions.html#default_parameter_values)。 Swift 用字符串插值(string interpolation)的方式把常量名或者变量名当做占位符加入到长字符串中,Swift 会用当前常量或变量的值替换这些占位符。将常量或变量名放入圆括号中,并在开括号前使用反斜杠将其转义: