ios 你如何在 swift 2 中执行 println()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31217024/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you do println() in swift 2
提问by TZE1000
I cant seem to find out how to do println()
in Swift 2.
我似乎无法println()
在 Swift 2 中找到方法。
I tried doing println(helloworld)
我试着做 println(helloworld)
That doesn't work
那不起作用
helloworld is a variable
helloworld 是一个变量
回答by Ashish Kakkad
No More println()
As per apple documentation:
不再println()
根据苹果文档:
In Swift 2.0 there is
在 Swift 2.0 中有
print("Hello")
for the new line you can set flag
对于新行,您可以设置标志
print("Hello", appendNewline: false)
Declaration
func print(_ value: T, appendNewline appendNewline: Bool)
Discussion
The textual representation is obtained from the value using its protocol conformances, in the following order of preference: Streamable, CustomStringConvertible, CustomDebugStringConvertible. If none of these conformances are found, a default text representation is constructed in an implementation-defined way, based on the type kind and structure.
宣言
func print(_ value: T, appendNewline appendNewline: Bool)
讨论
文本表示是使用其协议一致性从值中获得的,优先顺序如下:Streamable、CustomStringConvertible、CustomDebugStringConvertible。如果没有找到这些一致性,则基于类型种类和结构以实现定义的方式构造默认文本表示。
回答by Joonwoo Kim
it's print("hello world")
. it's changed in swift 2.0 and you need to see Apple's website. put print()
instead of println()
它是print("hello world")
。它在 swift 2.0 中发生了变化,您需要查看 Apple 的网站。把print()
而不是println()
回答by Claudio Guirunas
Use quotation marks:
使用引号:
println("helloworld")
and in swift 2.0, use print():
在 swift 2.0 中,使用 print():
print("helloworld")