Using implicit class to override method

Viewed 4445

My intention is to change the behaviour of the == method in String to call equalsIgnoreCase.

This code

implicit class LowerCase(s: String) {
      override def ==(that: LowerCase) = that.equalsIgnoreCase(this)
}

results in this error

error: type mismatch;
 found   : MyClass.LowerCase
 required: String
      override def ==(that: String) = that.equalsIgnoreCase(this)
1 Answers
Related