Defining an anonymous function that takes in a variable length of arguments

I am trying to define an anonymous function that takes in a variable number of arguments.

val a = { (a: Int*) => 1}

The compiler gives the error :')' expected but identifier found.

For a method I would define a variable number of arguments this way :

def func(a : Int*) : Int =???

And this compiler. Why doesn’t it work for annonymous function?

Unfortunately varargs syntax is not supported in anonymous functions.

1 Like

Ah…okay.