« »
12/10/2013

Scala equivalent of JavaScript ~.apply and Python unpacking

In Scala unpacking arguments in the context of a method call is achieved with an array argument followed by a colon and an _* symbol, like so:


Applying an array argument only works with functions that use repeated parameters, like print[A](args: A*) above.


Note: JavaScript Function::apply, requires a calling object as the first argument and works on any function (unlike in scala) so it's not quite the same.
« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.