I would like to filter my data set on two conditions at once.
Is it possible?
I want something like this:
mystuff = mystuff.filter(_.isX && _.name == "xyz")
I would like to filter my data set on two conditions at once.
Is it possible?
I want something like this:
mystuff = mystuff.filter(_.isX && _.name == "xyz")
While there might be some performance impact depending on what "myStuff" is, you could always filter twice
Using slightly less concise lambda syntax:
You can find more detail on Scala anonymous function syntax here.
If you need to frequently filter with several predicate, you could define a way of combining them:
Here is how to use it to keep only the odd numbers bigger than 10:
It easy to write
Or
andNot
combinators in the same fashion.