I'm trying to writing a generic max method for Scala Enumeration
values. I have
def enumMax[E <: Enumeration, V <: E#Value](v1: V, v2: V): V = v1.compare(v2) match {
case x if x > 0 => v1
case x if x < 0 => v2
case _ => v1
}
but I'm getting the rather cryptic error message
[error] overloaded method value compare with alternatives:
[error] ((that: _1.Value)Int) forSome { val _1: E } <and>
[error] (that: _1.Value)Int
[error] cannot be applied to (V)
[error] def enumMax[E <: Enumeration, V <: E#Value](v1: V, v2: V): V = v1.compare(v2) match {
[error] ^
Does anybody know what's going on here? Is there a better way to accomplish this? Thanks.
Connected question: Deriving a Cats Order for Scala's Enumeration