It doesn't really matter, since 42 is subsumed into Integer anyway.
Null is the weirdo (as always.)
On 9/8/2021 2:42 AM, Remi Forax wrote:
Hi all,
the current spec support merging/fallthrough cases only when there is a case
null,
like
case null, case Integer i -> // i can use 'i' here
First, i'm not sure it's clearly written in the spec, i was not able to pinpoint the rule allowing it.
Then i wonder if this special behavior is special because null is special or if
it should work with any values of the type of the type pattern,
i.e. it works because null is a possible value of Integer, in that case, it
should also work with any other values like 42
case 42, case Integer i -> // i can use 'i' here
So is null a special value or does this rule also work with any values.
regards,
Rémi