in reply to Re: Build your array with push
in thread Build your array with push
I use the former idiom as well, but I've run across this style a couple of times, too:
my @array = ( 'Hibbs' ,'Daglish' ,'Schwartz' ,'Vroom' );
The one time I had the chance to actually ask a coder about that style, he gave me two rationales. First, he liked it because of a string-cat convention that's similar:
my $string = 'this is a very long string that has a certain number ' .$number .' of segments.' ."\n";
In print statements, this coder often mirrored that convention using commas instead of periods to pass the list of strings to print. (This is apparently faster, though it smacks of premature optimization to me. But I digress.)
The second reason was that he found the trailing comma to be confusing; by moving commas to the front, he provided a visual reminder to put the comma in when adding to the list but without the "confusing" trailing comma. To each their own, I guess.
Anyone have thoughts on this style? Just curious as to what advantages/disadvantages there might be.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Build your array with push
by ikegami (Patriarch) on Feb 06, 2006 at 17:50 UTC |