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

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s