Created
June 4, 2013 01:50
-
-
Save kaja47/5703019 to your computer and use it in GitHub Desktop.
Dr. Strangelove or: How I Learned to Swap Two Variables In Place and Love the XOR
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
| var a: Int = 100 | |
| var b: Int = 200 | |
| a = a ^ b | |
| b = b ^ a | |
| a = a ^ b | |
| println(a) // 200 | |
| println(b) // 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment