In my venture to learning Scala, I created the following hierarchy:
trait Animal {
val name: String = "Animal"
}
trait HasLegs {
this: Animal =>
val numLegs: Int
}
abstract class Terrestrial extends Animal with HasLegs {
val name: String = "Terrestrial"
}
class Dog(val name: String) extends Terrestrial {
def numLegs = 4
override def toString = {
f"My name is: $name%s. I'm a Dog and I've $numLegs%d legs. I'm from the ${super.name}%s family."
}
}
However, the compiler complains that in Dog.toString
"super may be not be used on value name". What am I doing wrong?