Created
October 13, 2015 08:30
-
-
Save hartbit/666421f6539416425558 to your computer and use it in GitHub Desktop.
inout vs UnsageMutablePointer
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
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