-
Notifications
You must be signed in to change notification settings - Fork 10
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
Enums #120
Comments
@KCreate Good idea, that gives us more opportunities to seperate the functions from other objects |
@KCreate But are the functions actually necessary? Any examples for a good use? |
Writing code with enums usually requires comparing them every so often. En example that comes to mind is checking whether a type of token is a keyword or not. enum Token {
Let
Const
If
Integer
func is_keyword() {
return self == Token.Let || self == Token.Const
}
} |
Enums can also have static methods
The values of an enum are Numeric values starting at 0, incrementing with each value added to the enum. The enum is represented as an object.
The above code is equivalent to the following object literal:
The text was updated successfully, but these errors were encountered: