Variable Type Arguments

I want to create a function that takes variable type parameters
It’s like func[Type1] or func[Type1, Type2] or func[Type1,…,TypeN]
For values we are able to put any number of argument like def foo[A](x: A*). I am wondering if same thing is possible for type parameters.
Is it possible on scala ?

If we look here
https://docs.scala-lang.org/scala3/reference/new-types/type-lambdas-spec.html
it seems impossible.

Syntactically no, but if you need the functionality, maybe you could accept a tuple type? Scala 2 doesn’t really offer tools for decomposing and manipulating tuple types (unless you use Shapeless, maybe?), but Scala 3 offers a lot in this area.

2 Likes

Many thanks

1 Like