In Python, we have the star (or "*" or "unpack") operator, that allows us to unpack a list for convenient use in passing positional arguments. For example:

range(3, 6)
args = [3, 6]
# invokes range(3, 6)
range(*args)

In this particular example, it doesn't save much typing, since range only takes two arguments. But you can imagine that if there were more arguments to range, or if args was read from an input source, returned from another function, etc. then this could come in handy.

In Scala, I haven't been able to find an equivalent. Consider the following commands run in a Scala interactive session:

Mistakenly marked as duplicate, whereas it is not. Scala has :_* operatoration, but it only works with varargs on the definition side: e.g. case class Things(xs: String*)
–
om-nom-nomFeb 22 '13 at 23:01

Agreed that it wouldn't make sense given all the args would have to be the same type. In the particular use case I'm considering, argList will actually come from splitting a string provided as input, and I would implicit def some conversions to turn Strings into those various types required by the function I'm trying to call. But even then, I would have to build a Tuple from a List, I suppose.
–
jeff303Feb 22 '13 at 23:14

1

Somebody build an HList, which is basically a list with a independent type for each element. Might be able to convert this to a tuple ... Just an idea.
–
Jens SchauderFeb 22 '13 at 23:25

1

@JensSchauder An idea which happens to be implemented by both Scalaz and Shapeless, though Shapeless takes it much further.
–
Daniel C. SobralFeb 23 '13 at 0:13

As you can see, a little more ceremony is required in Scala with shapeless. This is because shapeless imposes compile time constraints which are guaranteed to be satisfied at runtime (unlike the python, which will fail at runtime if args is the wrong size or contains elements of the wrong type) ... instead you're forced to specify the type you expect the List to have (in this case exactly three Strings) and be prepared to handle the case where that expectation isn't satisfied (because the result is explicitly an Option of ThreeValues).