List Literals, list ranges



Things in () separated by commas are called a list of things.
A list is an ordered set of scalar values.
Examples of lists:
examples/arrays/list_literals.p6
#!/usr/bin/perl6
use v6;

(1, 5.2, "apple");          # 3 values 

(1,2,3,4,5,6,7,8,9,10);     # nice but we are too lazy, so we write this:
(1..10);                    # same as (1,2,3,4,5,6,7,8,9,10)
(1..Inf);                   # represent the list of all the numbers
(1..*);                     # this too

("apple", "banana", "peach", "blueberry");   # is the same as
<apple banana peach blueberry>;              # quote word

my ($x, $y, $z);               # We can also use scalar variables as elements of a list

We actually don't even need the parentheses in most of the cases.


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