Enums basics (EDIT: and Bug?)

About Monkey 2 Forums Monkey 2 Programming Help Enums basics (EDIT: and Bug?)

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Mark Sibly 1 year, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8293

    abakobo
    Participant

    two questions (EDIT:+ bug found on 2nd post?):

    -are we supposed to declare new enums like I did in the following code ‘e:myEnum’ and assign them their default member? (the code works fine but may I do that?)

    -is there a way to get binary shifts members with some kind of flag while declaring an enum or should we do it as I did in the code below?

    [/crayon]
    #8294

    abakobo
    Participant

    I have some unexpected behaviuor here! Am I doing something wrong or should i post an issue?

    [/crayon] [/crayon]
    #8322

    Mark Sibly
    Keymaster

    Yes, that’s how enum’s work. There’s no mechanism for auto-generating ‘mask’ enum values, eg: 1 Shl 1, 1 Shl 2, 1 Shl 3 etc. I find it useful to use hex for these:

    As for the ‘bugs’, I think you might be getting operators ‘|’ and ‘+’  mixed up! X|Y is NOT the same as X+Y. The code is working, but your enum values have multiple bits set so you’re getting weird values when you ‘|’ them together.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.