On Fri, Apr 11, 2008 at 3:16 PM, Robert Dober <robert.dober / gmail.com> wrote: > On Fri, Apr 11, 2008 at 2:39 PM, David A. Black <dblack / rubypal.com> wrote: > > Hi -- > > > > > > > > On Fri, 11 Apr 2008, Robert Dober wrote: > > > > > > > > > > > [false,nil][rand(2)].send([:&&,:||][rand(2)], > > > > method_returning_a_completeley_random_object) > > > > > > > oops, whats going wrong in my brain I was 100% sure that && was a > > > method, but :&& is not even a symbol, what is the reason for that? > > > I am obviously missing the obvious.... > > > > > > > I'm not sure what the exact rule is, but for operators I think you > > always have to quote them to get their symbol: > > > > :"&&" > No David > irb(main):017:0* x=:& > irb(main):018:0* 15.send x, 8 > => 8 > irb(main):019:0> > > The simple "problem" is that I believed for 3 years that &&, ||, :and > and :or where methods (of Object), which they are not :( > irb(main):020:0* 15.send("&&", 42) > NoMethodError: undefined method `&&' for 15:Fixnum > from (irb):20:in `send' > from (irb):20 > from :0 > > and unless somebody can point out a good reason why that is like that > I am really tempted to make a RCR for 1.9. > Opinions? > > Thx in advance > Robert Because the use of these operators is that in some cases you don't want the right hand to evaluate. result = long_operation or other_long_operation stops evaluating after the first one returns non-nil/false ^ manveru > > > > -- > http://ruby-smalltalk.blogspot.com/ > > --- > Whereof one cannot speak, thereof one must be silent. > Ludwig Wittgenstein > >