4 ms·
>Bitmasks are nicer than arrays of string constants. Well, arrays of string constants are categorically the wrong tool for the job if you're talking about the
by mistercow 13y ago
>Bitmasks are nicer than arrays of string constants.
Well, arrays of string constants are categorically the wrong tool for the job if you're talking about the function of a bitmask. You want a set for that, not an array. And it's not a bad idea to go ahead and use a dictionary since you can get the same functionality, and that will let you seamlessly add in non-boolean options down the line.
Except in tightly optimized code, I really think that using bitmasks is an antipattern. It's way harder to inspect a bitmask than a set or dictionary when debugging, and code dealing with them tends to be less readable. In addition, bitmasks sometimes have a tendency to encourage developers to be "clever" and do manipulations with them beyond simple &s and |s. Maintaining such code is, of course, a nightmare.