Generic wildcards in variable declarations in Scala
问题 In Java I might do this: class MyClass { private List<? extends MyInterface> list; public void setList(List<MyImpl> l) { list = l; } } ...assuming that ( MyImpl implements MyInterface ) of course. What is the analog for this in Scala , when using a Buffer ? import java.lang.reflect._ import scala.collection.mutable._ class ScalaClass { val list:Buffer[MyInterface] = null def setList(l: Buffer[MyImpl]) = { list = l } } This (of course) doesn't compile - but how do I declare the list variable