Skip to content
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 with char values #194

Open
fregas opened this issue Oct 17, 2018 · 2 comments
Open

enums with char values #194

fregas opened this issue Oct 17, 2018 · 2 comments

Comments

@fregas
Copy link

fregas commented Oct 17, 2018

Other Mono/.NET languages like C# allow enums to have a char data type instead of ints. Would be nice to do the same for Boo, or any other data types that are typical.

@masonwheeler
Copy link
Contributor

That's interesting. I'd never heard of this before.

I just checked it out in C#, and it builds, but when I opened it in ILDasm, the enum field in question was typed as int32, not char, with its value being the ordinal value of the char. Seems like this is just the C# compiler magically making chars equal to ints, which kind of surprises me because I thought that that was one of the (many!) old, ugly C-isms that C# did away with.

Is there a particular use case here?

@fregas
Copy link
Author

fregas commented Oct 17, 2018

Yeah it may just be syntax sugar C# is doing.

I use enums all the time. its nice because the value can be somewhat readable (a is for apple,b is for bannana,c is for cucumber, etc.) for different options or correlate to something besides an integer. In my case, I'm looking to convert an enum from C# to Boo in unity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants