Capturing Values

Run Settings
LanguageSwift
Language Version
Run Command
func makeIncrementer(forIncrement amount: Int) -> () -> Int { var runningTotal = 0 func incrementer() -> Int { runningTotal += amount return runningTotal } return incrementer } func incrementer() -> Int { runningTotal += amount return runningTotal } let incrementByTen = makeIncrementer(forIncrement: 10 incrementByTen() // returns a value of 10 incrementByTen() // returns a value of 20 incrementByTen() // returns a value of 30 let incrementBySeven = makeIncrementer(forIncrement: 7) incrementBySeven() // returns a value of 7 incrementByTen() // returns a value of 40 incrementBySeven() // returns a value of 14
Editor Settings
Theme
Key bindings
Full width
Lines