Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
Created June 4, 2014 12:23
Show Gist options
  • Save YellowAfterlife/bff775a891232270a3f3 to your computer and use it in GitHub Desktop.
Save YellowAfterlife/bff775a891232270a3f3 to your computer and use it in GitHub Desktop.
Value swap macros for Haxe
class Main {
macro static function swap(a, b) {
return macro { var v = $a; $a = $b; $b = v; };
}
static function main() {
var i = 10, j = 15;
trace(i, j); // 10, 15
swap(i, j);
trace(i, j); // 15, 10
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment