> Is there an equivalent of "union" in Dart?
No. Do you really need it in a high-level language?
The way I see it, unions are useful for two things: implementing tagged records (which you already have in the form of classes) and playing with bits and bytes (low-level work which you don't want to do in Dart anyway, there are better languages for that).
LT
I think that the point is, that we don't have a union type annotation,
where we can note that a parameter should be one of two types. I know
I've seen cases where I want this, and I bet others have too.
I have seen where the type of an input parameter is checked against
two types, and dispatched to different code depending on the type. I
think we don't have a perfect solution for this at the moment. But
people wanting pattern matching have a requirement that extends this
one, so a solution for pattern matching on input parameters would
cover this case too.
*sponsored link* http://demo.adts.googlecode.com/git/main.html *sponsored link*
I think that the point is, that we don't have a union type annotation,
I think that the point is, that we don't have a union type annotation,
where we can note that a parameter should be one of two types. I know
I've seen cases where I want this, and I bet others have too.
--