在 scala-swing 中,我可以编写以下简单代码:
import scala.swing._
object HelloWorld2 extends SimpleSwingApplication {
val top = new MainFrame()
top.title = "Hello, World!"
top.contents = new Button("a")
}
它工作正常,但根据文档,contentsin的类型MainFrame是Seq[Component],而 Button 的类型是Button。那为什么我可以写
top.contents = new Button("a")
没有错误?