Skip to content

Instantly share code, notes, and snippets.

@kaja47
Created June 4, 2013 01:50
Show Gist options
  • Select an option

  • Save kaja47/5703019 to your computer and use it in GitHub Desktop.

Select an option

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
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