-
Notifications
You must be signed in to change notification settings - Fork 5
repl
Blake Merryman edited this page Jan 29, 2015
·
1 revision
REPL stands for Read-Evaulation-Print-Loop. This is a real-time, interactive Swift environment. Basically, you type code, press enter, and it runs immediately. It's a great place to learn and experiment with Swift.
Open Terminal.app and type swift to launch the REPL. Now you can type in everything from simple println() to defining your own functions.
# Type "swift" to launch the REPL
...$ swift
Welcome to Swift! Type :help for assistance.
# Simple expressions
1 > println("Hello, Github!")
Hello, Github!
# Defining a function
2 > func add(x: Int, y: Int) -> Int {
3 > return x + y
4 > }
# Calling a previously defined function
5 > let order = add(22,44)
order: Int = 66Typing :help displays a long list of options that there to help you debug and analyze your REPL code.
> This article assumes you have your Mac set up according like [this]().