Aug 22, 2017 · 1 min read
You are right about “wrong” implementation in Java. But that was my point — I imagine many Java developers will come up with that solution, not the better one which you proposed. In general, in OOP-focused language one would not normally expect such gimmicks from functional world.
Then, that would work to some extent, but still will look rather awkward in Java, since there is no smart cast and no possibility to have an exhaustive when().
