On 02/05/13 06:45, Antoine Pitrou wrote: > I was talking in the context where subclassing is allowed. I don't > think there's a use-case for subclassing of non-empty enums. On the > other hand, empty enums should probably allow subclassing (they are > "abstract base enums", in a way). If you google for "subclassing enums" you will find many people asking how to subclass enums. Apparently Apache's Java allows subclassing, if I'm reading this correctly: http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/enums/Enum.html So do Scala and Kotlin. The most obvious use-case for subclassing enums is to extend them: class Directions(Enum): north = 1 east = 2 west = 3 south = 4 class Directions3D(Directions): up = 5 down = 6 If you allow enums to have methods, then the most obvious use-case is to add or extend methods, no different to any other class. -- Steven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4