Reputation: 95
I want to match a String
returned from someFunction
and have the default case return the String
from the someFunction
.
someFunction(input) match {
case "123" => "234"
case "234" => "345"
case _ => _
}
Where case _ => _
returns what someFunction(input)
actually returns. Is this possible?
Upvotes: 1
Views: 37
Reputation: 52681
You just need to name the default case:
someFunction(input) match {
case "123" => "234"
case "234" => "345"
case x => x
}
Upvotes: 6