Advertisement
Guest User

Untitled

a guest
May 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. def add(that: Rational): Rational =
  2. new Rational(
  3. this.numer * that.denom + that.numer * this.denom,
  4. this.denom * that.denom
  5. )
  6.  
  7. def add(that: Int): Rational =
  8. add(new Rational(that, 1))
  9.  
  10. def +(that: Rational): Rational =
  11. new Rational(
  12. this.numer * that.denom + that.numer * this.denom,
  13. this.denom * that.denom
  14. )
  15.  
  16. def +(that: Int): Rational =
  17. +(new Rational(that, 1))
  18.  
  19. (fragment of Rational.scala):19: error: value unary_+ is not a member of this.Rational
  20. +(new Rational(that, 1))
  21. ^
  22.  
  23. def +(that: Int): Rational =
  24. this + (new Rational(that, 1))
  25.  
  26. def add(that: Int): Rational =
  27. this add (new Rational(that, 1))
  28.  
  29. def +(that: Int): Rational = this.+(new Rational(that, 1))
  30.  
  31. def unary_+: Rational = this.+(new Rational(that, 1))
  32. val a = new Rational(3,2)
  33. val b = +a
  34.  
  35. def +(that: Int): Rational =
  36. +(new Rational(that, 1))
  37.  
  38. def +(that: Int): Rational =
  39. this +(new Rational(that, 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement