type Set = Int => Boolean /** * Indicates whether a set contains a given element. */ def contains(s: Set, elem: Int): Boolean = s(elem)
Why does
Set here is a function from Int to Boolean, so calling s(someInt) returns a boolean, you have of course to provide that function:
Set
Int
Boolean
s(someInt)
def contains(s: Set, elem: Int): Boolean = s(elem) contains({ someInt => someInt == 1 }, 1) // returns true