3 ms·
Enumerations (from: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html#//apple_ref/d
by solutionyogi 12y ago
Enumerations (from: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html#//apple_ref/doc/uid/TP40014097-CH12-XID_185 https://developer.apple.com/library/prerelease/ios/documenta...):
Unlike C and Objective-C, Swift enumeration members are not assigned a default integer value when they are created. In the CompassPoints example above, North, South, East and West do not implicitly equal 0, 1, 2 and 3. Instead, the different enumeration members are fully-fledged values in their own right, with an explicitly-defined type of CompassPoint.
+100 for that. This will help developer avoid whole class of bugs.
Enumerations also support associated values. Enums in .NET are very poorly defined. Looks like Swift got it right.
- jevinskie 12y agoIndeed. Luckily C++11 took care of the issue on the C++ side. http://en.wikipedia.org/wiki/C++11#Strongly_typed_enumerations http://en.wikipedia.org/wiki/C++11#Strongly_typed_enumeratio...
- platz 12y agoDo Swift's enumerations allow recursive definitions?
- oldguysrule 12y ago>Unlike C and Objective-C, Swift enumeration members are not assigned a default integer value when they are created Well that’s gonna make storing persistent values tricky.