Skip to content

Instantly share code, notes, and snippets.

@vikingosegundo
Last active September 21, 2022 09:25
Show Gist options
  • Save vikingosegundo/592cd74c67a42b404765ae0316e49e44 to your computer and use it in GitHub Desktop.
Save vikingosegundo/592cd74c67a42b404765ae0316e49e44 to your computer and use it in GitHub Desktop.
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