我想設置一個變量的上限。斯卡拉的上限
trait Container {
type A <: Number
def value: A
}
然後,當我試圖得到一個值,我
object AnyNumber extends Container {
def value = 2
}
我得到這個錯誤
<console>:25: error: overriding type A in trait Container with bounds <: Number;
type A has incompatible type
type A = Int
^