In article <BEEOLJOGDFLPOHNICOIEIEEFCAAA.calum.shaw-mackay / virgin.net>,
Calum Shaw-Mackay <calum.shaw-mackay / virgin.net> wrote:
>'Lo all
>
>I'm impressed with both Ruby and JRuby - I mainly program in Java so ruby's
>OOP is fairly natural

Actually, if you're used to Java, Ruby should seem supernatural ;-)

>
>I've got a question regarding some code I've ported...
>
>I have a fixnum which is essentially a bit flag
>i.e.
>a=1,b=2,c=4,d=8 and so on
>I use binary & to work out if a particular flag is set and output a given
>message, unfortunatley this leads to lots of puts x if(value & CONST_A) ==
>CONST_A
>I pass in the messages in an array but the code looks very C-ish - is there
>any construct in ruby that will allow me to get around this long winded code
>without having a large array of boolean values
>
>I thought something along the line of {pseudo codey}
>
>mesgs = {}
>.... # Fill a with mesgs
>bitflags.each {|flag| puts mesgs[flag] if flag}
>
>Would this be going along the right lines?

Seems like a reasonable way to do it.  I'm not quite understanding what 
you're putting in the bitflags array, but I figure that it's an array of 
true/false/nil values (right?) 

Phil