SPUG: Chained comparisons in Perl 6

Michael R. Wolf MichaelRWolf at att.net
Mon Dec 22 18:52:17 PST 2008

At last week's meeting, there was a question about code like this:

     if ($left < $middle < $right) { ... }

This is *not* legal Perl5 since the comparison operators are non- 
associative (contrary to my side comment at the time).  It will cause  
a compile error in Perl5, and must be written as.

     if ($left < $middle && $middle < $right) { ... }

For those who are interested in the nitty-gritty, search for "Chained  
comparisons" in this Perl6 "Spec" (FKA "Synopsis") on "Perl Operators".


Or "perldoc perlop" in Perl5.

Michael R. Wolf
     All mammals learn by playing!
         MichaelRWolf at att.net

More information about the spug-list mailing list