-
-
Save milanpanchal/dc93a435e9454b41166db992eb1691c7 to your computer and use it in GitHub Desktop.
Swift ++ operator
This file contains 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
prefix func ++(inout x: Int) -> Int { | |
x = x + 1 | |
return x | |
} | |
postfix func ++(inout x: Int) -> Int { | |
let oldX = x | |
x = x + 1 | |
return oldX | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment