-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enumerated types #105
Comments
Proposal
|
|
Dart got them recently, in a version simpler than Java (which can associate any arbitrary data to an enum value), but still useful. |
You can loop the values with:
|
Enums might as well reuse the object syntax: enum WeekDay {
sunday: 1,
monday: 2,
tuesday: 3,
wednesday: 4,
thursday: 5,
friday: 6,
saturday: 7,
} What's the advantage of using an enum over a regular object? That it's immutable? |
@Skalman We can use |
@Skalman look at my example above. Imagine enum with 100 values. I'd like to have them automatically increased. |
@Namek, I meant object-like syntax, i.e. using I also prefer @alongubkin's version, where values are strings, not numbers ( |
@Skalman It's not about a preference. Look at first post once again, both are possible. How do you even use enums not wanting integers in there? |
I think enums aren't very useful in a language without type checking. A simple object works just as well in Spider. In swift enums are useful, as you can use Obviously this feature has no obvious downsides, but it makes sense to keep Spider simple, and avoid features of little value. |
I just came across a case where I could've used an enum rather than a bunch of constants. Not saying Spider should necessarily have them, but it's worth discussing.
The text was updated successfully, but these errors were encountered: