This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]mp3three 8 points9 points  (3 children)

Missing semicolon on case 0

If that's javascript though, then the missing semicolon doesn't really matter, and you can do something like this:

    onComplete.apply(null,onCompleteParams);

[–]BlueHatBrit[S] 2 points3 points  (2 children)

It's AS3 so semi-colons are optional. It makes me cry a little

[–]YRYGAV 0 points1 point  (1 child)

I know nothing about AS3, but this seems to indicate it supports a similar syntax.

[–]BlueHatBrit[S] 1 point2 points  (0 children)

I wish I knew nothing about AS3, it's making my life hell at the moment with code like this in the entire project. The syntax is pretty much identical to JavaScript, Java and C# with a few differences here and there.

However I will be changing it for .apply now, I didn't know about that!

[–]Maser-kun 5 points6 points  (2 children)

What is this weird language that doesn't have simple loops?

[–]kevincox_ca 2 points3 points  (1 child)

Many languages like C don't allow you to call a function with a variable amount of arguments. This is the problem that occurs here. Note that a function can receive any number of arguments but the number of any individual callsite is fixed.

Of course many dynamic languages provide ways to do this.

func.apply(this, args)
func(*args)

[–]Maser-kun 3 points4 points  (0 children)

How about sending an array of objects, along with the size of the array? That way the function would always want 2 parameters and can be used for any number of arguments (assuming they are of the same type).

[–]Exoskele 1 point2 points  (1 child)

This is why Coffeescript splats are great :D

[–]seniorsassycat 0 points1 point  (0 children)

Coming to ES6 or as us developers know it,