Last active
September 21, 2022 09:25
-
-
Save vikingosegundo/592cd74c67a42b404765ae0316e49e44 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 adder = createAdder(x: 5) | |
print(adder(4)) // -> 9 | |
print(adder(4)) // -> 13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment