Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delegates in Haxe

Tags:

haxe

Is there something like a delegate in Haxe?

This would come in handy when I use a anonymous function but still want to maintain the current class'es variable scope.

myObject.callback = function(param) { this.variable = param; };

As you can see this is not accessible from within the function body. :-(

like image 503
nepa Avatar asked Aug 08 '26 18:08

nepa


1 Answers

As far as I know you can do it in latest Haxe version. In earlier versions you should be able to do:

var t=this;
myObject.callback = function(param) { t.variable = param; };
like image 95
Piotr Praszmo Avatar answered Aug 11 '26 17:08

Piotr Praszmo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!