In your helper class you define the type B
in the class initialization. But that type is unknown until the method >
or <
usage.
My solution would be this.
implicit class RichList[A](input: List[A]) {
def >[B](that: List[B]): Boolean = input.size > that.size
def <[B](that: List[B]): Boolean = input.size < that.size
}
Edit
Since you asked, why its not possible in other way, consider following example.
List(1,2,3) > List("1", "2")
We hope this will implicitly expand to (This wont happen)
new RichList[Int, B](List[Int](1,2,3)).>(List[String]("1", "2"))
But, type B
is not resolved to String
. Therefore, compiler neglects this implicit conversion, and gives a compilation error.