Hello,
sub myfunc {
my @x=(1,2,3);
return \@x;
}
# or,
sub myfunc {
my @x=(1,2,3);
return [@x];
}
which one is the better way to return the list content? And if the
method is an instance method?
Thanks.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands
On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote:
> Hello,
>
> sub myfunc {
> my @x=(1,2,3);
> return \@x;
> }
>
> # or,
>
> sub myfunc {
> my @x=(1,2,3);
> return [@x];
> }
>
> which one is the better way to return the list content? And if the
> method is an instance method?
F
On Mon, 18 Aug 2014 16:17:53 +0800
Ken Peng wrote:
> sub myfunc {
> my @x=(1,2,3);
> return \@x;
> }
>
> # or,
>
> sub myfunc {
> my @x=(1,2,3);
> return [@x];
> }
# or
sub myfunc {
return [ 1, 2, 3 ];
}
--
Don't stop where the ink does.
Shawn
--
To unsubscribe, e-mail:
On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote:
> On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote:
>> which one is the better way to return the list content? And if the
>> method is an instance method?
>
> Functionally, the two are identical. The first is returning a reference
> to