From: Sebastian Hungerecker Date: 2008-02-15T07:18:58+09:00 Subject: Re: Problem usning 'OR' operator in 'IF' condition? dare ruby wrote: > but it works fine when the condition changes like, > >      if @character == 'R'  || @character == 'r' >         raise " Expected 'R' after 'E' in version Declaration" >       end Here you are saying: if character is 'R' or if it is 'r'. This condition obviously can be true (if it is one of 'r' or 'R') or false (if it's something else). Previously you were saying: if character is something other than 'R' or it is something other than 'r'. This will, as Paul pointed out, always be true. Just think about: If character is 'R' than the first part won't be true ('R' is not different from 'R'), but the second part will (because 'R' is different from 'r'). If it is 'r', it's the other way around. And since the whole expression is true when (at least) one of the parts is true (that's what "or" means), it's always true. What you want is: !(@c == 'R' || @c=='r') which is equivalent @c != 'R' && @c != 'r'. Note how here you have && instead of ||. That's the law of DeMorgan that Paul mentioned: !(a && b) <-> !a || !b !(a || b) <-> !a && !b HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826