Comparison Operators


Two sets of relation operators. One is to compare numerically the other is to compare as strings, based on the ASCII table.

See also S03-operators.pod

examples/scalars/comparison_operators.p6
#!/usr/bin/perl6
use v6;

say 4      == 4 ?? "TRUE" !! "FALSE";     # TRUE
say 3      == 4 ?? "TRUE" !! "FALSE";     # FALSE
say "3.0"  == 3 ?? "TRUE" !! "FALSE";     # TRUE
say "3.0"  eq 3 ?? "TRUE" !! "FALSE";     # FALSE
say 13     >  2 ?? "TRUE" !! "FALSE";     # TRUE
say 13     gt 2 ?? "TRUE" !! "FALSE";     # FALSE
say "foo"  == "" ?? "TRUE" !! "FALSE";    # TRUE
say "foo"  eq "" ?? "TRUE" !! "FALSE";    # FALSE
say "foo"  == "bar" ?? "TRUE" !! "FALSE"; # TRUE
say "foo"  eq "bar" ?? "TRUE" !! "FALSE"; # FALSE


Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC
If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed