Printing Your Results

When you use the playground to test your code, you have two options for printing data. You can simply just write it, like this:

var someString = "hi there"someString //prints "hi there" in the output area

You can also use println(), which prints to the console output area. When you are making a full-fledged app, compiling code outside a playground, you’ll want to use println(), like this, because just writing the variable will not do anything:

var someString = "hi there"println(someString) //prints "hi there" in the console output

Get Learning Swift™ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.