1
votes

I'm working on a project that's integrating with StrobeMediaPlayback and have been having trouble working out why I can't get my media loaded.

One of the two available public functions for the class is:

public function loadMedia(..._):void

If this is a rest parameter, there's no use of '_' as an argument list within the function.

What's going on here? The class extends Sprite, so its not a case of an override.

1
Where are you seeing that signature defined? Is it in an ASDoc for a particular library?James Tomasino

1 Answers

2
votes

It is the ... (rest) parameter.

The parameter does not need to be called rest; it can have any name that is not a keyword.

Valid variable names start with a non number character and can include alphanumeric characters, the underscore and the dollar sign. So _ is a valid name for a parameter.

The question why exactly the parameter was named that way can probably only be answered by the author of that function. So here's what I think: Aside from its use as a short variable name for often used objects (like $ as shorter name for jQuery in javascript), the name _ is sometimes used as a placeholder, or unused variable. If I understand the question right, an the variable isn't even used in the function, it probably was added for future use. This way the API wouldn't need to be changed once the feature based on this parameter will be implemented. The developers maybe thought that a parameter name with semantic meaning could confuse the users, as they would expect it to actually doing something.