I am trying to get this working in Scala:
class MyClass(some: Int, func: AnyRef* => Int) {
}
The above code won’t compile (why?) but the following does:
class MyClass(some: Int, func: Seq[AnyRef] => Int) {
}
That’s OK but are the two equivalent? And if so, then how can I then use func inside MyClass?
The first one (with varargs) works if you use parentheses:
The two forms of
func, however are not the same. The first version takes a vararg input, so you would call it likefunc(a,b,c,d), but the second version takes aSeqas input, so you would call it likefunc(Seq(a,b,c,d)).Compare this:
to this: