Splat operator in Supercollider?

Forgive me if this question has been answered elsewhere, it might well be I’m not using the proper Supercollider vocabulary, hence haven’t been able to find an answer.

Many languages know a splat or spread operator, effectively spreading out an array as arguments to a function or method. Ruby has def method(*args) ... end, ES6 knows function(...args) {}.

Is there something similar in SC?

For the record, I’m trying to fill a VLayout with a bunch of premade views:

w.layout_(VLayout(~collection.views)).front;

but that of course doesn’t work since I’m passing in an array, and not an argument list. Is there a way to achieve this in SC?

Thank you!

Aaaand of course it’s been answered in this very minute :man_facepalming: (I think)

I’ll leave this topic here though, in case anyone uses the splat/spread wording.

One distinction:

f = { | ... args | /* code... */ }; is a feature of a function definition which takes an arbitrary list of arguments given separately in the function call, and collects them into an array passed to one argument.

f.value(*array) is a feature of function calls where multiple values are bundled as an array, and then spread out over multiple argument names in the function definition.

When you wrote “ES6 knows function(...args) {},” this is referring to the function definition feature where function call values : function arguments is M : 1.

When you asked about “I’m trying to fill a VLayout with a bunch of premade views: w.layout_(VLayout(~collection.views)),” this is the opposite feature: function call values : function arguments is 1 (single array) : M.

The other thread happens to answer the latter question – pure chance that it was coincident.

hjh

You are of course correct. Syntactically similar, but different semantics.

Still happy to see that it’s supported in SC!