Chapter 3. Playgrounds

In this chapter, we will cover the following topics:

  • Introduction to Playgrounds
  • Introduction to the Swift language
  • Handling loops
  • Creating logic (conditionals)
  • Functions and parameters
  • Understanding classes and structures
  • Extensions to classes
  • Operator overloading

Introduction

Programming has always been considered difficult. It is not only because of the complexities of logic or the syntax of the language; it has been so also because of the tools available to work with. The second issue is that to test a single line, you have to write the code in an editor, then compile it, and run it to finally see the results; tedious for a single line of code. If you have to test a function, and there is a line that has a bug, it is not easy to debug that unless you have an integrated debugger that allows you to go line by line and add watches, and print out the values of the variables. The mere mention of the "issue" makes it sound complicated. Apple has released a new feature as part of Xcode 6 called Playgrounds. This is largely based on the principles of live coding where one can change the code without having to recompile it. Think of it as a scratchpad that executes your code with each keystroke you type into the editor, without having to even run it. It displays errors and warnings unobtrusively allowing you to continue writing your code and also indicating where the issues are.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.89.85