To clarify, in the above scenario in dart I can have an input with type MyEnum and do this?
switch myEnum {
case let one:
// react to this here
case let two(twosChild: twosChild):
// call an API passing in a child element of twosChild here
case let three(threesGenericChild: threesGenericChild):
// T: Protocol, and call an extension function threesGenericChild.extension() here?
case let four(foursCallbackChild: foursCallbackChild):
// Pass foursCallbackChild callback into another context, and execute an escaping closure if needed?
}
Last I checked Dart required a nested if/else tree and didn't have compiler-guarantees of switch completeness like the above.
Correct, Dart has enum exhaustiveness checks, associated types, and expressions as of 11-13 months ago: https://cfdevelop.medium.com/dart-switch-expressions-33145c3... (keeping it short and simple because I'm at -2 on the original post, don't want to look like I'm argumentative)
To clarify, in the above scenario in dart I can have an input with type MyEnum and do this?
switch myEnum {
case let one:
}Last I checked Dart required a nested if/else tree and didn't have compiler-guarantees of switch completeness like the above.