Sophie

Sophie

distrib > Fedora > 15 > x86_64 > by-pkgid > 1e007a96761035f261351a68e7601417 > files > 862

parrot-docs-3.6.0-2.fc15.noarch.rpm

# Copyright (C) 2007-2009, Parrot Foundation.

=head1

PMC registers can contain array or hash data types, or more
advanced types based on these two. If a PMC type implements
the array or hash interfaces, they can be accessed using
integer or string keys.

An array is a type of PMC that contains a collection
elements indexed by number. Array indices must be integer
values, not floating point ones.  Arrays also have a large
group of special opcodes that operate on them: C<push>,
C<pop>, C<shift>, and C<unshift>.

=cut

.sub main :main

    .local pmc myarray
    myarray = new ['ResizableStringArray']

    myarray[0] = "Foo"
    push myarray, "Bar"
    unshift myarray, "Baz"

    $S0 = join " ", myarray
    say $S0

    $S1 = myarray[2]
    print $S1
    print "'\n"

    $S2 = pop myarray
    say $S2

    $S3 = shift myarray
    say $S3

.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: