in reply to Re: Variable declaration optimization?
in thread Variable declaration optimization?
my( $var1, $var2 ) = ( subroutine0_with_return_value(), subroutine1_with_return_value() );
but I'm lazy and I find that:
my $var1 = sub_w_ret_val1(); my $var2 = sub_w_ret_val2();
is the easiest to think through, especially when assigning several return values.
but I was taught that:
(note the language change)public static void main(){ int var1, var2; //declare more variables here var1 = sub_w_ret_val(); var2 = sub_w_ret_val(); }
was the correct method for declaring variables.
while I'm not saying I find the third is the best method for declaring and using variables, I sometimes find myself doing the Perl (is it Perl or perl?) equivalent.
my $file1, $file2 my $var1, $var2 $var1 = &sub_w_ret_val(); $var2 = &sub_w_ret_val();
any way, that's my two cents on code writing optimization.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Variable declaration optimization?
by chromatic (Archbishop) on Oct 13, 2010 at 02:18 UTC |