YAP6 Operator: Comparisons - Part I

by Adriano Ferreira

Another article of the series "Yet Another Perl 6 Operator"

As expected, Perl 6 supports the usual comparison operators. This includes the numeric comparison operators:

== != < <= > >=

(where '!=' is a short for '!==', the negated version of '=='). These operators convert their terms into numbers before comparison.

The string comparisons operators are here as well.


2007-09-28 16:42:40
AWESOME... this is great stuff.. awesome article.. I was really hoping that perl6 would address some issues like this one. Chaining is SO much easier to read than the endless Or's and And's cluttering up my code..
2007-09-29 09:21:29
Wait for corrections and updates, as there was no time to submit this article for review. Some examples were copied verbatim from Synopsis 03.

Are you beholden to some schedule? If not, why not wait until you're sure that it's right to avoid spreading misinformation. If so, why? It's not like perl6 is...
2007-09-30 18:47:09
Would it be possible for you to keep the introduction webpage up-to-date with links to all the other entries in this series? I'd like to have one page I can bookmark to see whether a new installment has been added.
Adriano Ferreira
2007-10-02 06:08:39

I am feebly trying to follow a schedule. But you're right and, from now on, publishing of articles may be delayed but they will be announced to get some feedback before going live.

Adriano Ferreira
2007-10-02 06:10:43

Ok, I will keep the index in the introduction webpage up-to-date. I am glad that it (apparently) stopped changing the URL after updates (which is some odd quirky due to MovableType).

Jason Porritt
2008-01-19 08:36:28

A chain of comparisons short-circuits: meaning that if a comparison fails, the remaining comparisons to the left never evaluate.

Pardon my nitpicking, but I think this statement needs to be corrected. Changing the word left to right makes sense in light of the example given.