This is not a valid type definition:
scala> type Addable = { def +(subject: Addable) }
<console>:4: error: illegal cyclic reference involving type Addable
type Addable = { def +(subject: Addable) }
Can this be expressed in scala?
This is not a valid type definition:
scala> type Addable = { def +(subject: Addable) }
<console>:4: error: illegal cyclic reference involving type Addable
type Addable = { def +(subject: Addable) }
Can this be expressed in scala?
Here's what I did in a library I wrote, HTH:
trait Addable {
type AddableType <: Addable
def + (subject: AddableType): AddableType
}
trait Rational extends Addable {
type AddableType = Rational
override def + (subject: Rational): Rational
}