Skip to content

Instantly share code, notes, and snippets.

@soywiz
Created September 2, 2014 20:13
Show Gist options
  • Save soywiz/3f9569fbcddae1fed1d0 to your computer and use it in GitHub Desktop.
Save soywiz/3f9569fbcddae1fed1d0 to your computer and use it in GitHub Desktop.
haxe macro swap
var a = 1;
var b = 2;
swap(a, b);
trace('$a, $b');
macro static public function swap(a:Expr, b:Expr) {
return macro {
var temp = $a;
$a = $b;
$b = temp;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment