Static nested classes
Allow declaring a class in the body of another class. ```dart class Person { class Occupation { String jobTitle; Occupation(this.jobTitle); String named(String name) => moniker(Person(name, this)); } String name; Occupation occupation; Person(this.name, this.occupation); static String moniker(Person p) => '${p.name} The ${p.occupation.jobTitle}'; } Person p = Person("Rosie", Person.Occupation("Riveter")); ``` I'd expect that `Occupation` is not an instance variable of `Person`, if that would even be a sensible notion in Dart, instead the outer class acts as a namespace containing the inner class. The inner class cannot be accessed from a `Person` instance. The inner class cannot capture instance variables from the outer class. It can howewer access static methods and fields. Nested classes could be used for: * Indicating a relationship between classes / encapsulating classes which only serve to complement another (e.g. Flutter `StatefulWidget`s and their respective `State`s) * Creating arbitrary namespaces like `export _ as _` but without a library declaration file * Encapsulating many related methods under a namespace
Posted by dz4k on Apr 29, 2019, 7:34 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Static nested classes
Allow declaring a class in the body of another class. ```dart class Person { class Occupation { String jobTitle; Occupation(this.jobTitle); String named(String name) => moniker(Person(name, this)); } String name; Occupation occupation; Person(this.name, this.occupation); static String moniker(Person p) => '${p.name} The ${p.occupation.jobTitle}'; } Person p = Person("Rosie", Person.Occupation("Riveter")); ``` I'd expect that `Occupation` is not an instance variable of `Person`, if that would even be a sensible notion in Dart, instead the outer class acts as a namespace containing the inner class. The inner class cannot be accessed from a `Person` instance. The inner class cannot capture instance variables from the outer class. It can howewer access static methods and fields. Nested classes could be used for: * Indicating a relationship between classes / encapsulating classes which only serve to complement another (e.g. Flutter `StatefulWidget`s and their respective `State`s) * Creating arbitrary namespaces like `export _ as _` but without a library declaration file * Encapsulating many related methods under a namespace
Comments (0)
No comments yet. Start the discussion.