Hi,
···
----- Original Message -----
From: "Michael Fellinger" <m.fellinger@gmail.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Friday, April 11, 2008 10:28 PM
Subject: Re: how to create random object to a particular ruby object ?
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 --
>
...
> :"&&"
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 :0and 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
RobertBecause 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_operationstops evaluating after the first one returns non-nil/false
I don't think so.
If you're correct, what's your explanation of the following:
irb(main):001:0> 15.send("||",42)
NoMethodError: undefined method `||' for 15:Fixnum
from (irb):1:in `send'
from (irb):1
&& or || is not a method but an operator.
You cannot use send for the operator.
Regards,
Park Heesob