Yes, I use a
case (here is the actual code), something like:
total = event.total
todo = event.todo
name = event.name
peer_data[event.peer] = PeerStatus.new(event.peer.address, :connected)
I ask because a type hierarchy is not quite an algebraic data type. The reason is that in other languages you can pattern match against an algebraic type and make sure you cover all cases
I see what you mean. Would switching to an exhaustive
case make this feel more like an ADT? Or would we still missing out on some properties?
I’d really like to add a Sealed attribute similar to what you can do in Sorbet, Kotlin and I think other languages, but others don’t seem to like or understand its usefulness.
I come from Scala’s sealed traits, so you have my full support on this