operator overloading

Ross
2006-08-11
2013-05-02
  • Ross
    Ross
    2006-08-11

    Can you pass an operator as a parameter?

     
    • B S
      B S
      2006-08-21

      Yes, an operator is a normal function.
      For example:
      list.foldLeft(`+`)

      `+` is the name of the function, nice just translates a+b into `+`(a,b), which can lead to error messages that look different from what someone might expect.

      `+`(a,b) is legal IIRC, and is just like a+b