[Sealed class] Language feature docs #4581
Labels
a.language
Relates to the Dart language tour
co.request
Community ask for documentation
e1-hours
Can complete in < 8 hours of normal, not dedicated, work
p2-medium
Necessary but not urgent concern. Resolve when possible.
st.triage.ltw
Indicates Lead Tech Writer has triaged
Summary
Sealed classes are a class modifier. Declaring a supertype class
sealed
means it can't be directly extended, implemented, or mixed in from outside their originating library.From the Class Modifiers spec:
Their motivating use case is exhaustiveness checking, a new feature of switch cases. They are the only class modifier that touch on patterns.
Evaluation
Document semantics with new Class modifiers content. Show how to use (just
sealed
keyword), show example of sealed superclass and subclasses, and what affect that has on subclasses.Content in class modifiers section shouldn't address exhaustiveness checking or patterns, but should link out to that content ("learn more about sealed classes use cases...).
Class modifiers content might go under the "Libraries" umbrella (side nav), or under the "Classes" section of the "Language" umbrella (see [Class modifiers] Language feature docs #4497)
In exhaustiveness checking content (which will be part of new switch content), link to semantic definition of the
sealed
class modifier.Then, go into detail on how sealed creates a closed hierarchy of classes, how that enables exhaustiveness checking that allows you to switch on object patterns.
IF we get to a point where we're documenting the collection of patterns features that enable functional style, then sealed classes will come up there (but that might be sufficiently covered by the description of exhaustiveness checking and switch)
MAYBE point to sealed content from enum content in language tour.
Something like "you can enumerate subclasses using the
sealed
class modifier..."Resources
The text was updated successfully, but these errors were encountered: