Hi I am trying to define a generic function isNonNeg that makes use of an arithmetic operator as follows:
scala> def isNonNeg[A](a:A): Boolean = { if (a >= 0.0) true else false}
However this produces the following error:
<console>:13: error: value >= is not a member of type parameter A
def isNonNeg[A](a:A): Boolean = { if (a >= 0.0) true else false}
^
I'm assuming that the problem is because type A is unknown. Is there a way of specifying that A should be a numeric type hence >= is a valid operator. Would some sort of type class or implicit parameter offer a solution ?