develooper Front page | perl.perl6.language | Postings from March 2005

List constructors

Thread Next
From:
wolverian
Date:
March 9, 2005 08:37
Subject:
List constructors
Message ID:
20050309155625.GB22323@sci.fi
Hi all,

reading [AS]02 left me a bit unclear on list construction. Specifically,
as comma still seems to be the list constructor, what do these produce:

    my $a       = (1, 2);   # a List object of 1, 2?
    my $a       = (1);      # Int 1?
    my $a       = (1,);     # List of 1?
    my ($a)     = (1, 2);   # Int 1? Or does it need *?
    my ($a,)    = (1, 2);   # Same as above, I hope...
    my ($a, $b) = (1);      # $a == 1, I presume

Also what do these rather esoteric cases do:

    my ()   = ();
    my $a   = ();
    my ($a) = ();

Syntax errors in a few of those are welcome. :)

--
wolverian

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About