Comment

Comment by RetpolineDrama

>Dart has it, last 12 months or so.

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.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton