Hi --

On Wed, 20 Dec 2006, Tom Pollard wrote:

>
> On Dec 19, 2006, at 9:58 PM, Luciano Ramalho wrote:
>
>> On 12/19/06, Peter Szinek <peter / rubyrailways.com> wrote:
>>> foo = false
>>> bar = true
>>> 
>>> baz = foo or bar
>>> 
>>> baz ends up false (because = has greater priority than or)
>> 
>> That sucks. Why would anyone want = to be evaluated before anything else?
>
> The point is that 'or' and 'and' have /lower/ precedence than anything else, 
> so that they can be used to chain complete expressions together.   This is a 
> Perl-ism, to my knowledge and a number of common Perl idioms are based on 
> this. (...like, 'open(my $handle, $filename) or die').  I'm a nuby here, but 
> I haven't seen the weak 'and' and 'or' used much in Ruby - at least, not in 
> the same circumstances where I'm used to seeing it in Perl code.

It's used somewhat less, partly because some of the "or die" things in
Perl raise fatal errors in Ruby already.


David

-- 
Q. What's a good holiday present for the serious Rails developer?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    aka The Ruby book for Rails developers!
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)