I am trying to write a function that returns a function based on the input parameter.
def myFunction(x: Int): x => Boolean {
x => if (x < 7) false
if (x % 2 == 0) false
else true
}
So if x is less than 7 or even false will be returned. Otherwise true is.
How do I write this using pattern matching?
And if it pointless to use pattern matching for Ints, what about something more complex like a list of Ints.
def myFunction(myList: List[Int]): x => Boolean {
// just doing something simple here real life is more complex.
x => if (myList.size() < 7) false
else true
}
Thanks.