Reputation: 7486
How to create method, that will be accepting only primitives or their Seq's? Moreover it should be var-arg.
def method(args: Param*)
where args are for example
method(1: Int, 1l: Long, "1": String, Seq(1, 3, 7))
the second condition is that it can NOT accept value classes
Upvotes: 1
Views: 76
Reputation: 22105
Define Param
like this:
sealed abstract class Param
object Param {
implicit final class IntParam(val x: Int) extends Param
implicit final class StringParam(val x: String) extends Param
...
implicit final class SeqParam(val seq: Seq[Param]) extends Param
}
Upvotes: 5