class Creature{
val range:Int=10
val env:Array[Int]=new Array[Int](range)
}
class Ant extends Creature{
override val range=2
}
运行时env的length为0,如果希望length为我们认为的2
需要
class Ant extends{
override val range=2
}with Creature
class Creature{
val range:Int=10
val env:Array[Int]=new Array[Int](range)
}
class Ant extends Creature{
override val range=2
}
运行时env的length为0,如果希望length为我们认为的2
需要
class Ant extends{
override val range=2
}with Creature
转载于:https://www.cnblogs.com/meiweijun/p/5488430.html