Skip to content

Instantly share code, notes, and snippets.

@memfrag
Last active August 29, 2015 14:04
Show Gist options
  • Save memfrag/eb6a8c88e1d602016cfc to your computer and use it in GitHub Desktop.
Save memfrag/eb6a8c88e1d602016cfc to your computer and use it in GitHub Desktop.
[Swift] Swap Operator
operator infix <=> {}
infix func <=> <T>(inout left: T, inout right: T) {
let tmp = left
left = right
right = tmp
}
var a = 1337
var b = 4711
a <=> b
// a is now 4711 and b is 1337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment