In natural languages, we would say \"some color is a primary color if the color is red, blue, or yellow.\"
In every programming language I\'ve seen, that translates
In perl 6 you could do this with junctions:
if $color eq 'Red'|'Blue'|'Green' {
doit()
}
Alternately you could do it with the smart match operator (~~
). The following is roughly equivalent to python's if value in list:
syntax, except that ~~
does a lot more in other contexts.
if ($color ~~ qw/Red Blue Green/) {
doit()
}
The parens also make it valid perl 5 (>=5.10); in perl 6 they're optional.