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

"flattening arguments"

Thread Next
From:
BÁRTHÁZI András
Date:
June 5, 2005 06:33
Subject:
"flattening arguments"
Message ID:
42A2FED3.7070501@barthazi.hu
Hi,

 From the Perl6 and Parrot Essentials:

----- 8< -----
sub flat_hash ($first, $second) {
     say "first: $first";
     say "sec. : $second";
}

my %hash = (first => 1, second => 2);

flat_hash(*%hash);
----- 8< -----

It says, that "No compatible subroutine found". I've modyfied the 
subroutine:

----- 8< -----
sub flat_hash (+$first, +$second) {
     say "first: $first";
     say "sec. : $second";
}
----- 8< -----

Now, I got:

first: first 1 second 2
sec. :

-----------------

I've tried it on the feather.perl6.nl machine, with pugs. Is it the 
right behaviour?

Bye,
   András

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