Skip to content

Instantly share code, notes, and snippets.

@vikingosegundo
Last active October 19, 2021 08:01
Show Gist options
  • Save vikingosegundo/cee16e996ba776f2bca7b1cdf164b877 to your computer and use it in GitHub Desktop.
Save vikingosegundo/cee16e996ba776f2bca7b1cdf164b877 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 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