No, * is only allowed for the ParamType parameter, which is the parameter type for an anonymous function or method.
4.6.2 Duplicate parameters Syntax: ParamType :: = Type 'The last value of the parameter of the parameter section may be the suffix "", for example. (..., x: T *). The type of such a repeating parameter inside the method is a sequence of type scala.Seq [T]. Methods with repeating T * parameters accept a variable number of arguments of type T.
The compiler error @Eastsun example is on the first line, not the second. This should not be allowed:
scala> type VarArgs = (Any*) defined type alias VarArgs
I raised a mistake .
This is a similar limitation for By-Name parameters. In this case, the compiler prevents the creation of an alias of the type:
scala> type LazyString = (=> String) <console>:1: error: no by-name parameter type allowed here type LazyString = (=> String)
Your last attempt is the standard way of expressing this.
retronym
source share