๐Ÿ“˜ Universal comparison operators before and after in Perl 6

๐Ÿ“˜ Universal comparison operators before and after in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.


before and after are the comparison operators, which work with operands of different types. It returns a Boolean value of either True or False depending on which operand was considered to be ordered earlier or later.

Type coercion is similar to how it happens with the cmp operator.ย  Remember that depending on the data types the comparison of similar-looking strings or numbers may give different results because the strings are compared alphabetically, while the numbers are ordered by their values:

say 10 before 2;ย ย ย ย ย  # False
say '10' before '2';ย  # Trueย 
say 10 before 20;ย ย ย ย  # True
say '10' before '20'; # True

Leave a Reply

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code