develooper Front page | perl.perl5.porters | Postings from October 2005

[perl #37186] push returning total number elements instead of number new elements

From:
Steve Peters via RT
Date:
October 1, 2005 22:10
Subject:
[perl #37186] push returning total number elements instead of number new elements
Message ID:
rt-3.0.11-37186-121885.10.9393250717064@perl.org
> [daveola - Fri Sep 16 13:38:40 2005]:
> 
> 
> This is a bug report for perl from perlbug@daveola.com,
> generated with the help of perlbug 1.35 running under perl v5.8.4.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> The return value for push is the total number of elements in the
>    array.
> 
> According to the docs, push:
> 
>   "Returns the new number of elements in the array."
> 
> Example code:
> 
>   my @j = (1..100);
>   print push(@j,42), "\n";
> 
> Should display 1, but it displays 101.
> 

The documentation of "push" has been clarified to indicate that it
returns the size of the array following the push.

Change 25678 by stevep@stevep-kirk on 2005/10/02 04:42:46

	Clarify the documentation regarding the return value from C<push>.



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