On 2020-01-20 20:09, ToddAndMargo via perl6-users wrote:
On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote:
Hi All,
What is the proper way to state that I am returning a
hash from a sub? `sub x() returns % {}`
And an array? `sub x() returns @ {}`
Many thanks,
-T
I think this is it:
> sub x() returns Associative { my %h= A=>"a"; return %h}
&x
> x
{A => a}
Yup, too high up the food chain:
> sub x() returns Hash { my %h= A=>"a"; return %h}
&x
> x
{A => a}
> sub y() returns Array { my @a=(1,2,3,2,1) ; return @a}
&y
> y
[1 2 3 2 1]
Am I too high up the food chain with Associative and Array?
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~