Does Haxe provide parameters by reference or make a copy?

Take this code:

function createGUIHud():Void { this.screen.gameHud = new NormalGameHud(10, 0, this.screen.getTextureAtlas()); this.screen.gameHud.x = FlxG.width - (this.screen.gameHud.width + GameSize.getPositionByPlatform(10)); this.screen.gameHud.y = GameSize.getPositionByPlatform(10); } // NormalGameHud.hx /** * @param lives * @param corn * @param textureAtlas */ public function new(lives:Int = 10, corn:Int = 0, textureAtlas:SparrowData) { super(0, 0, 30); this.lives = lives; this.cornCount = corn; this.textureAtlas = textureAtlas; this.createScoreboard(); this.createLivesCount(); this.createCornCounter(); } 

Does 'textureAtlas' get passed by reference or copied?

http://api.haxeflixel.com/flixel/util/loaders/SparrowData.html

I know that PHP passes objects by reference, and things like arrays are copied unless otherwise specified (with the & prefix). Does the same apply to Haxe?

Thanks.

+6
source share
1 answer

AFAIK, Primitives (Int, Float, Bool, ...) are passed by value. Everything else is passed by reference.

+5
source

All Articles