Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MacroTools
- {
- // returns an array declaration of length len, filled with values 'val'
- @:macro static public function array(len:Int, val:haxe.macro.Expr)
- {
- var arr = [];
- for (i in 0...len)
- arr.push(val);
- return macro $[arr];
- }
- }
- //--------------------------------------
- //usage :
- //var arr = MacroTools.array(3,-1);
- // will be compiled as :
- //var arr = [-1,-1,-1];
Advertisement
Add Comment
Please, Sign In to add comment