I have trait Device { val name: String; val label = "Device: " + name } and class Pump extends Device { val name = "pump-1" }. Printing new Pump().label gives Device: null. Changing label to def or lazy val fixes it, but I do not understand why.
What exactly is the difference between val, var, lazy val and def in terms of when the right-hand side is evaluated?




