11

I cant seem to find out how to do println() in Swift 2.

I tried doing println(helloworld)

That doesn't work

helloworld is a variable

TZE1000
  • 348
  • 3
  • 5
  • 13
  • print and println function has been merged to a single method in Swift2. It is available in Xcode7 beta. – Amit89 Jul 04 '15 at 04:57
  • 1
    If you type `println("Hello world")` in Xcode 7, the error message *"'println' has been renamed to print"* immediately pops up, together with a *"Fix it: replace 'println' by 'print'"* suggestion. – Martin R Jul 04 '15 at 09:20

4 Answers4

21

No More println() As per apple documentation :

In Swift 2.0 there is

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.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136
20

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()

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Joonwoo Kim
  • 259
  • 2
  • 14
4

Use quotation marks:

println("helloworld")

and in swift 2.0, use print():

print("helloworld")
Claudio Silva
  • 3,743
  • 1
  • 26
  • 27
4

Using Xcode 7.0 Beta 6, the solution on my end, including getting rid of the annoying new line character:

enter image description here

Mike
  • 9,765
  • 5
  • 34
  • 59