Chapter 3
Accessing Swift’s Compiler and Interpreter: REPL
Let’s now investigate how to access the Swift compiler from the command-line interface known as the Read-Eval-Print-Loop, or REPL. This is where you can interact with the compiler by entering statements, which the compiler will interpret and evaluate immediately.
What is REPL?
The REPL is an interactive shell that’s similar to the Unix shell and those of other languages like Lisp, Ruby, and Python. When you start the shell, you are given a prompt to enter your code. The compiler interprets and evaluates the code and then prints either the result or an error.
If you don’t have Terminal in the Dock, locate the Terminal app in the Utilities folder and drag it to the Dock, then launch ...
Get Learn Swift on the Mac: For OS X and iOS 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.