开发者

Delegates in Haxe

开发者 https://www.devze.com 2023-04-09 00:55 出处:网络
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.

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. :-(


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; };
0

精彩评论

暂无评论...
验证码 换一张
取 消