From: "Brian Schröder" Date: 2005-08-19T01:37:50+09:00 Subject: Re: unless statement... why oh why? On 18/08/05, Brock Weaver wrote: > Sorry, to be a little more clear, the following 3 lines are all > equivalent (notice the parens in line 2): > > if not thr or not thr.alive? > unless (thr or thr.alive?) > unless thr and thr.alive? > > It's easiest for me to think of "unless" == "if not". What's funny is > that "if not" is no longer than "unless", so the "unless" keyword > doesn't buy us much. > I am quite shure that the above is not correct. if (not thr or not thr.alive?) is equal to if not (thr or thr.alive?) and unless (thr and thr.alive?) and unless thr and thr.alive? Proof: irb(main):008:0> [[false, false], [false, true], [true, false], [true, true]].map do | a, b | [("No Parens" unless a or b), ("Parens" unless (a or b))] end => [["No Parens", "Parens"], [nil, nil], [nil, nil], [nil, nil]] regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/