Created
June 4, 2014 12:23
-
-
Save YellowAfterlife/bff775a891232270a3f3 to your computer and use it in GitHub Desktop.
Value swap macros for Haxe
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
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