Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add(that: Rational): Rational =
- new Rational(
- this.numer * that.denom + that.numer * this.denom,
- this.denom * that.denom
- )
- def add(that: Int): Rational =
- add(new Rational(that, 1))
- def +(that: Rational): Rational =
- new Rational(
- this.numer * that.denom + that.numer * this.denom,
- this.denom * that.denom
- )
- def +(that: Int): Rational =
- +(new Rational(that, 1))
- (fragment of Rational.scala):19: error: value unary_+ is not a member of this.Rational
- +(new Rational(that, 1))
- ^
- def +(that: Int): Rational =
- this + (new Rational(that, 1))
- def add(that: Int): Rational =
- this add (new Rational(that, 1))
- def +(that: Int): Rational = this.+(new Rational(that, 1))
- def unary_+: Rational = this.+(new Rational(that, 1))
- val a = new Rational(3,2)
- val b = +a
- def +(that: Int): Rational =
- +(new Rational(that, 1))
- def +(that: Int): Rational =
- this +(new Rational(that, 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement