I need to check if a string is in the list and call a function that takes a boolean accordingly.
Can this be achieved with a single liner?
The code below is the best I could get:
val strings = List("a", "b", "c") val myString = "a" strings.find(x=>x == myString) match { case Some(_) => myFunction(true) case None => myFunction(false) }
I am sure that this can be done with less coding, but I do not know how to do this.
string list scala find
Dario Oddenino Jan 10 '13 at 21:30 2013-01-10 21:30
source share