Use anonymous function when pattern matching element(s) rather than explicitly using the match
keyword when possible. This approach/syntax is cleaner, improves readability and is easy to comprehend.
list.foreach {element =>
element match {
case foo =>
case bar =>
case _ =>
}
}
list.foreach {
case foo =>
case bar =>
case _ =>
}