Re:Guide to Java Virtual Threads
by pron on Thursday March 16, 2023 @09:22AM
(#35181584)
Both. Java has records for products, sealed hierarchies for sums, and offers pattern matching over them. See https://www.infoq.com/articles/data-oriented-programming-jav...
[ Parent
| on HN ]
Re:Guide to Java Virtual Threads
by DeathArrow on Friday March 17, 2023 @05:44AM
(#35194998)
>sealed hierarchies for sums
I wouldn't call that a good example of sum types. You can use sealed classes or other mechanism in C# to emulate sum types. I was thinking about something built in the language.
Example:
type IntOrBool = | I of int | B of bool