Skip to content

Instantly share code, notes, and snippets.

@hartbit
Created October 13, 2015 08:30
Show Gist options
  • Save hartbit/666421f6539416425558 to your computer and use it in GitHub Desktop.
Save hartbit/666421f6539416425558 to your computer and use it in GitHub Desktop.
inout vs UnsageMutablePointer
let closure1: (inout Int) -> () -> Void = { a in
return {
a = 1
return
}
}
let closure2: (UnsafeMutablePointer<Int>) -> () -> Void = { a in
return {
a.memory = 2
return
}
}
var value: Int = 0
closure1(&value)()
print(value)
closure2(&value)()
print(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment