Playgrounds are interactive work environments in Xcode that let us write code and see the results immediately.
To start with a Playground, the first thing we need to do is to start Xcode.
The left pane is the editor area where you type your code into the playground. The right pane is the output from the complier with results.
The first line(blue text) in the editor is a comment.
The next line imports the cocoa api.
The third line declare a variable named “str” and initializes it to a value “Hello, playground”.
The variable is of String type. So, if you try to reassign it to a variable of different type(such as Int), the compiler will generate an error as shown in below screenshot :
We have modified the default program to print a message :
This application prints “Hello John Doe”
© 2016, www.topjavatutorial.com. All rights reserved. On republishing this post, you must provide link to original post