From: Calum Shaw-Mackay Date: 2003-04-02T07:03:47+09:00 Subject: Newbie....ish - with questions! 'Lo all I'm impressed with both Ruby and JRuby - I mainly program in Java so ruby's OOP is fairly natural 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? Thanks in advance Calum