Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你知道是否有一种简单的方法可以将一些参数传递给通过调用的函数
haxe.Timer.delay(func, delay);
“简单”是指不创建任何自定义计时器。
你可以用bind()这个。例如,如果您想调用someFunction("abc"):
bind()
someFunction("abc")
haxe.Timer.delay(someFunction.bind("abc"), 1000); // 1s
在 Haxe 3 之前,您可以使用callback:
callback
haxe.Timer.delay(callback(someFunction,"abc"), 1000); // 1s
一切都可以通过额外的间接级别来实现:-)
看起来你需要一个闭包,它唯一的工作就是用参数调用另一个函数。
像这样的东西(未经测试):
haxe.Timer.delay(function () { func(arg1, arg2); }, delay);