I’m doing some pattern matching on a colon delimited String as follows:
case s:String => s.split(":") match {
case Array("foo","bar") => ...
case Array("hello",_,_) => ...
...
}
How can I rearrange the code to assign a name to the array returned by s.split(":")?
I’ve tried the following to no avail:
case s:String => val x = s.split(":") match {
case Array("foo","bar") => // try to use x here
...
}
Or