小编OoS*_*OoS的帖子

参数类型+函数需要一个字符串作为第二个参数?

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

2
推荐指数
1
解决办法
826
查看次数

标签 统计

scala ×1

type-mismatch ×1

type-parameter ×1

types ×1