Skip to content

Instantly share code, notes, and snippets.

@longngn
Created January 3, 2017 15:48
Show Gist options
  • Save longngn/5adfc5a35969ab5c068c6354743e4207 to your computer and use it in GitHub Desktop.
Save longngn/5adfc5a35969ab5c068c6354743e4207 to your computer and use it in GitHub Desktop.
test code
func square(a: Int) -> Int {
return a * a
}
func apply(modifier: (Int) -> Int, array: [Int]) {
for a in array {
a = modifier(a)
}
}
var a = [1,2,3,4]
apply(square, a)
// a == [1,4,9,16]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment