I want to be able to declare something like this:
trait Narrowable[A] extends Iterable[A] {
def narrow[B <: A & B <: AnyRef] : Iterable[B]
}
That it, the type B
should be both a subtype of A
and AnyRef
. Is this possible?
I want to be able to declare something like this:
trait Narrowable[A] extends Iterable[A] {
def narrow[B <: A & B <: AnyRef] : Iterable[B]
}
That it, the type B
should be both a subtype of A
and AnyRef
. Is this possible?
Use Compound Type:
trait Narrowable[A] extends Iterable[A] {
def narrow[B <: A with AnyRef] : Iterable[B]
}