I have
val str = "abc:def"
val pattern = "(.*):.*".r
val prefix = str match {
case pattern(prefix) => prefix
case _ => ""
}
I want to avoid MatchError so if it matches I will return the match otherwise I will return "". This compiles and do extract "prefix = "abc". However I get a warning saying
Suspicious shadowing by a Variable Pattern
IDE is suggesting putting `` around pattern(`prefix`).
Is there a better way of doing this? Why is the IDE suggesting that solution.