Scala

Scala

Made by DeepSource

Use anonymous pattern-matching functions instead of match blocks within iterators SC-R1001

Anti-pattern
Major

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.

Bad practice

list.foreach {element =>
  element match {
    case foo =>
    case bar =>
    case _ =>
  }
}

Recommended

list.foreach {
  case foo =>
  case bar =>
  case _ =>
}