-
Notifications
You must be signed in to change notification settings - Fork 218
Open
Labels
featureProposed language feature that solves one or more problemsProposed language feature that solves one or more problems
Description
75% of my union usage in TS is
void method(data: A | B)
As the proposal says, intersection is hard, so maybe for now Dart could avoid data.something
where something exists in both A and B.
But... Just having A | B in the parameter and being able to switch between them would be extremely helpful for me!! I hate using dynamic or object. And I hate using a second variable that's not null when the first one is.
So, this would be extremely helpful to me:
int method(data: A | B) =>
switch(data) {
A: return 1,
B: return 2,
}
Yet I hear "is" is really really expensive. So maybe this is faster than comparing by "is" twice.
Any thoughts?
I'm not sure opening an issue is the correct path, just wanted to contribute to the discussion.
rubenferreira97
Metadata
Metadata
Assignees
Labels
featureProposed language feature that solves one or more problemsProposed language feature that solves one or more problems