class TestClass[T](val x: T) { def +(other: TestClass[T]) = x + other.x }
这个定义给了我以下编译错误:
错误:类型不匹配; found:T required:String def +(其他:TestClass [T])= x + other.x
是不是可以使用Int或Double作为类型参数并在Scala中使用添加?
types scala type-mismatch type-parameter
scala ×1
type-mismatch ×1
type-parameter ×1
types ×1