>>>>>>
Probably precedence.

    nil && (nil + 12.0)

?
<<<<<<<<

No, the result is the same.

    irb(main):001:0> nil && (nil + 12.0)
    => nil
    irb(main):002:0> nil && (2.0 + 12.0)
    => nil

The problem is that because of short-cut evaluation, if the LHS of the && is nil, the result of the entire expression always going to be nil.

That°«s why, when the RHS would result in an error, the error doesn°«t happen  because the RHS will *never* happen.  Ruby already has the answer to the expression and doesn°«t bother looking further.

If this worked then there would have been no need to introduce the lonely operator, &.

From: ruby-talk [mailto:ruby-talk-bounces / ruby-lang.org] On Behalf Of Matthew Kerwin
Sent: 06 May 2017 00:44
To: ruby-talk ML
Subject: RE: Patching Float within a scope

Probably precedence.

    nil && (nil + 12.0)

?

Cheers


On 5 May 2017 20:48, "Andy Jones" <Andy.Jones / jameshall.co.uk<mailto:Andy.Jones / jameshall.co.uk>> wrote:
>>>>>>>>
Why not just guard it?

answer = nil && nil + 12.0
<<<<<<<<
Perhaps I am being dense, but I don°«t think that does what you think it does:

    %:  irb
    irb(main):001:0> nil && nil + 12.0
    => nil
    irb(main):002:0> nil && 2.0 + 12.0
    => nil

It rather looks as if it returns nil under all circumstances?


Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org<mailto:ruby-talk-request / ruby-lang.org>?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>



Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>