I m试图在口译人员内装上一个Schala档案:
trait MyOrdered {
def <(that: MyInt):Boolean = compare(that) < 0
def >(that: MyInt):Boolean = compare(that) > 0
def <=(that: MyInt):Boolean = compare(that) < 0 || this == that
def >=(that: MyInt):Boolean = compare(that) > 0 || this == that
def compare(that: MyInt): Int
}
class MyInt(val value: Int) extends MyOrdered {
def compare(that: MyInt) =
if (this.value < that.value) -1
else if (this.value == that.value) 0
else 1
}
object App extends Application{
val a = new MyInt(2)
val b = new MyInt(4)
println(a < b)
println(a > b)
}
但是,我有sil误:
Loading traits.scala...
<console>:8: error: not found: type MyInt
def <(that: MyInt):Boolean = compare(that) < 0
^
<console>:12: error: not found: type MyInt
def compare(that: MyInt): Int
我怎么能让口译员了解在公路上界定的<代码>MyInt级?