Book Image

Mastering Cocos2d Game Development

By : Alex Ogorek
Book Image

Mastering Cocos2d Game Development

By: Alex Ogorek

Overview of this book

Table of Contents (15 chapters)
Mastering Cocos2d Game Development
About the Author
About the Reviewers

Learning Swift through Playgrounds

Playgrounds offer a way to test your Swift code quickly and easily without much baggage that usually comes when creating a test project in another language. They're intended as files used for prototyping and quick fiddling with code if you have problems with a small section. They're really easy to use and understand, so let's begin.


The first thing you'll notice about Swift is that there are no semicolons required (except when writing multiple statements on one line, which must be separated by semicolons). That's right—none! They're optional, but the preferred style of writing Swift code is without semicolons.

Also, when coding if statements, loops, switch statements, and so on, you must use curly braces around the block of code that will be run (even if there's only one line of code that will be executed).

Right now, go ahead and open the SwiftSyntax.playground file in the Sample Projects folder included with this book.


If you cannot open the file within...