3 ms·
While I agree that some syntax sugar would be welcome here (AFAIK the best you can currently do is sealed interface Tree permits Tree.Leaf, Tree.Node { r
by kaba0 3y ago
While I agree that some syntax sugar would be welcome here (AFAIK the best you can currently do is
sealed interface Tree permits Tree.Leaf, Tree.Node {
record Leaf(int value) extends Tree {}
record Node(..) extends Tree {}
}
), it is not too terrible. Also note that rust really mixed up the nomenclature here with their enums, these were known in every language previously simply as ADTs. It makes sense for these to not have identity, while java enums are always a single instance.
- vips7L 3y agoYou want `implements Tree` here or this won't compile.