Can the spread operator be used to supply function arguments?

You currently can use the spread operator only for collection literals ([] for List, {} for Map or Set).

From Bob Nystrom’s article introducing Dart 2.3’s new features:

A spread can only appear in a place that can gracefully handle
receiving zero or more values. Without completely overhauling the
language’s execution model and turning it into Icon (which I find
strangely appealing, but probably not practical…), there aren’t too
many places that fit that constraint. Basically collection literals
and maybe positional argument lists. (I wrote a proposal for the
latter
, but it’s quite complex so we aren’t doing it, at least not
right now.)

That proposal doesn’t quite cover what you want, which is to spread a Map into optional named arguments, however.

Leave a Comment