On 08/02/06, Claudio Jeker <cjeker / diehard.n-r-g.com> wrote: > Hello, > > there is one thing in ruby that annoys me most (at least for now). > > if 0 > puts "true" > end > > Yes, I know everything expect nil and false are true but that's probably > the most illogic part of ruby. Because of this stuff like > > if flags & 0x01 > # do some stuff if flag is set > end This is your coding problem. It should be -- even in C/C++: if (flags & 0x01 == 0x01) ... end > will execute in any case. Perhaps I'm biased because I'm a crazy C hacker > but I can not believe that others do not fall into this trap. I realy like > the clearness of the ruby syntax but this "everything but nil and false is > true" logic is totaly non obvious and annoying. Why? What is it about zero that makes it non-true? After all, in bash: foo && bar # runs bar if and only if foo returned 0! In shell scripting, 0 is the *true* value and everything else is false. Just as there's no meaningful sort order for "true", "false", there's no meaningful interpretation of "0" as "false". It's merely a C-style convention that should be abandoned with relish. > IMO if it looks like a boolean expression it should act like a boolean > expression. Neither expression ("if 0" or "if flags & 0x01") looks like a valid boolean expression to me. -austin -- Austin Ziegler * halostatue / gmail.com * Alternate: austin / halostatue.ca