Perl 6 An Introduction to Perl 6 #16

Junctions

A junction is a single value that is equivalent to multiple values.

(1|2|3) + 4              # 5|6|7

Create junctions using "any", "all", "one", and "none", or the infix operators '|' and '&'

unless $roll == any(1..6) { print "invalid roll"; }

if $roll = any(4, 5, 6) { print "High roll"; }

if $roll == 1|2|3 { print "Low roll"; }

if none @a == $elem { print "$elem is not in @a"; }
Copyright © 2008 Patrick Michaud