> I'd like an object to have binary states (each state is either true of > false). If I were using plain C, I'd do ... > is there some convenience and fast function? Well, if you want bit-operations they are all there already. Just look http://dev.rubycentral.com/ref/ref_c_fixnum.html#Bitoperations or the same for Bignums. With bignums you're not hitting the limit of 31 avalable flags. Just a reminder, you should write the if in Ruby like if flag & MY_CONSTANT_FLAG_BIT_REPRESENTATION != 0 ^^^^ and the usage of the constants would be about the same as in C. The other way round is to use plain index as constant: if flag[MY_CONSTANT_FLAG_BIT_INDEX] != 0 What's the best way to name those indexes is then a matter of taste. Coming from the Perl land might lead one to use hashes like indexLookup["flag_foo"]=2, but this, of course, has a performance penalty. I guess in Ruby you could make, at least, a constant generator, so adding or removing a constant wouldn't cause any manual changes to the code like in C: > typedef enum > { > FLAG_FOO = 1 << 1, > FLAG_BAR = 1 << 2, removing FLAG_FOO so that there's always room at the end of the integer: typedef enum { FLAG_BAR = 1 << 1, The interface for the enum creator could be something like attr_* has: enum :flag_foo, :flag_bar But I think I've seen something related to enums somewhere, just can't recall...or I've imagined...in either case I'm getting too old :). - Aleksi