Chapter 2

Playing in the Playground

In This Chapter

arrow Trying out code in a playground

arrow Spotting syntax errors in a playground

arrow Observing values as code runs

One of the important features of Swift and Xcode 6 is the playground, a tool that you can use to experiment with syntax and code to get immediate response. You’ll use playgrounds frequently in the exercises in this book to explore snippets of syntax.

You can build a playground for a section of code that you want to test repeatedly, but you can also create a playground to test code on the fly. When your test is complete, you can keep the playground or just throw the playground away.

This chapter provides an overview of playgrounds. Stepping through the examples in this chapter can help you get the hang of playgrounds and allow you to explore some basic Swift snippets.

Some of the snippets in this chapter have syntax errors in them. This is deliberate. The purpose of this is to demonstrate the way Xcode deals with typos. Somewhere in the universe there may be a place where software engineers always write error-free code, but Planet ...

Get Swift For Dummies 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.