DEV Community

Discussion on: Scala - pattern matching (exploring different solutions)

Collapse
 
6zow profile image
Max Gorbunov

Try this:

(name, marriage) match {
  case ("Anne", 0) => true
  case ("Catherine", years) if years >= 2 => true
  case _ => false
}

Or this:

(name, marriage) match {
  case ("Anne", 0) => true
  case ("Catherine", 1) => false
  case ("Catherine", _) => true
  case _ => false
}