in reply to Need clean code
You mentioned: $var or $var = 30;
Better as:
which assigns the value if the value of $var is not true. If your code allows $var to be defined but not true at that point (e.g. hold a value of '0'), then use:$var ||= 30;
which will only assign the value to $var if it is undefined.$var //= 30;
See perlop for more information.
Hope this helps!
|
|---|