So in my case it seems the .bind() thing works with both the class method as well as with a local arrow function:
class Threads {
static function main() {
// uses method
Thread.create( threadAcceptingArguments.bind("hi!") );
Sys.sleep( 0.5 );
// uses local arrow function
var j = ( n:Int ) -> { trace( 'n=$n' ); };
Thread.create( j.bind(10901) );
Sys.sleep( 0.5 );
}
static function threadAcceptingArguments( string:String ) {
trace( string );
}
}
Output:
src/Threads.hx:5: hi!
src/Threads.hx:10: n=10901
I think this is still impressive that Thread.create( job:()->Void ) does accept “bind arguments” for job… I heard of bindings before, but now I’m glad they exist I guess.
edit: Maybe I should also say I only tried this with HashLink (!), maybe it won’t work on all platforms the same way (?)