You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code snippet below print "Boo" 4 times which is wrong, it should only print 3 Boo and a 'Go New York'.
val matchNY = "^.*New.*$".r
val teams = List(
"Toronto Raptor",
"New York Nets",
"San Francisco 49ers",
"Dallas Mavericks"
)
for (team <- teams) {
team match {
case `matchNY` => println("Go New York.")
case _ => println("Boo")
}
}
The text was updated successfully, but these errors were encountered:
@retronym said:
You are checking if "Toronto Raptor" == matchNY.
Please address follow-up questions to [scala-user] or StackOverflow, and reserve the bug tracker for issues where you've double checked the behaviour on such a forum.
@retronym said:
I've opened #7211 to issue a warning in this case; the compiler knows that a String can't be equal to a Regex, either because a) String is final and doesn't inherit Regex, or b) both are classes, and other classes can only inherit one.
The code snippet below print "Boo" 4 times which is wrong, it should only print 3 Boo and a 'Go New York'.
The text was updated successfully, but these errors were encountered: