Cannot resolve symbol error in intellij with Scala with Odersky's programming in scala book -


i'm following martin odersky's programming in scala book (second edition, page 101) learn scala. received resolve symbol error in intellij when following code. code is:

class rational (n: int, d: int) {   require( d != 0)   val numer: int = n   val denom: int  =d   override def tostring = numer + "/" + denom    def add(that: rational): rational =   new rational (     numer * that.denom + that.numer * denom, denom * that.denom   ) }  val onehalf= new rational(1,2) 

the error received says cannot resolve symbols that.denom or that.numer. however, code run , compile when called produd=ce 1/2. can explain why error occurs?

edit: want add im using scala worksheet part of intellij idea


Comments