Even more fun, what do you think happens: (Seq(0): Seq[Int]) match { case _: List[Int] => 1 case _ => 2 }
-
-
-
The same, presumably...? ;)
- Show replies
New conversation -
-
-
Issued my answer, and I’m working under the assumption that: - scalac warns about erasure - pattern matching on types is equivalent to isInstanceOf, so the static type doesn’t matter So, 1 with warning?
-
No, though the mistake is in one (or maybe both) of the assumptions... It's very subtle, though.
- Show replies
New conversation -
-
-
Something-something, generic matching warning. But the output is 1
-
Well, you're half right...
End of conversation
New conversation -
-
-
It's looking as a split among votes... I wonder what the answer is (I'm far from the computer now to check)
-
Yeah, the split is very satisfying!
End of conversation
New conversation -
-
-
Dotty actually checks that the element type is matched correctly while Scala 2 takes a lucky guess and comes to the same conclusion?
-
I'm not sure Scala 2's guess is lucky... and as far as I can tell, Dotty does not do anything any differently.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.