You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to declare an enum inside the class and it gave me an error stating can't have enum inside a class. I wanted to know the reason why but I didn't find anything on the internet. Declaring enum inside a class is allowed by major languages why not dart?
The text was updated successfully, but these errors were encountered:
Oh, I also thought that this might be the case. But why doesn't dart allow nested class? I just want to know I also understand that this might sound naive.
Dart does not allow nested classes mainly because it's simpler not to.
If you nest classes, there are two ways to do it:
Static nested classes, which really is just a way to put the declaration into the namespace of the other class, but is otherwise the same as declaring another top-level class.
Virtual classes, where subclasses inherit the class and can perhaps even override it.
The latter is pretty complicated, and not something we have found a good enough reason to prioritize yet.
The former is fairly simple, but also not very powerful, so it too hasn't been a priority.
I tried to declare an enum inside the class and it gave me an error stating can't have enum inside a class. I wanted to know the reason why but I didn't find anything on the internet. Declaring enum inside a class is allowed by major languages why not dart?
The text was updated successfully, but these errors were encountered: