Scala pattern match default guards

Viewed 5916

I want to do many case statements with same guard in front of each. Can I do it in way that doesn't require code duplication ?

"something" match {
   case "a" if(variable) => println("a")
   case "b" if(variable) => println("b")
   // ...
 }
3 Answers
Related