I’m trying to use the negation of a boolean function in Scala, such as:
def someFunction(x: Set, p: Int => Boolean): Boolean =
someOtherFunction(x, !p)
But I get the error:
value unary_! is not a member of Int => Boolean
How can I refer to the negation of p?
The negation of
pis a function that appliespto its argument and negates the result.If you want to be able to write
!porp && qyou can use this library, which pimps functions that return a bool with various logical operators.