I was experimenting with operator precedence in Scala, and there is something strange happening here:
class Op{
  def +(that:Op):Op={println("called +");this}
  def -(that:Op):Op={println("called -");this}
  def *(that:Op):Op={println("called *");this}
  def /(that:Op):Op={println("called /");this}
  def %(that:Op):Op={println("called %");this}
}
val op = new Op;
op+op-op*op/op%op ;
op+op*op ;
For the first line, the output is:
called +
called *
called /
called %
called -
(Notice + is called before *.) However, for the second line, the output is:
called *
called +
(* is called before +.) I believe from what I read here that * should be called before +. Is there something I got wrong?
 
     
    