Last active
October 19, 2021 08:01
-
-
Save vikingosegundo/cee16e996ba776f2bca7b1cdf164b877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createAdder(x:Int) -> (Int) -> Int { | |
var value = x | |
return { | |
value = value + $0; return value | |
} | |
} | |
let add = createAdder(x: 1) | |
add(2) // -> 3 | |
add(2) // -> 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment