Groovy:
Scala:
Note, Scala requires types for values x and y.
{ x, y -> ...}
Scala:
(x:Stirng, y:String):String => { ... }
Note, Scala requires types for values x and y.
{ x, y -> ...}
(x:Stirng, y:String):String => { ... }
val regEx = "apple*".r
val name = ....
name match {
case regEx => // do your processing here
case entry => // like default, possibly throw an error
}
val zipMatch = "(\\d+)-(\\d+)"
val zip = "12345-1234"
zip match {
case regEx(num1, num2) => // num1 == 12345, num2 == 1234
case entry => // do nothing
}