in reply to Re^2: What is the difference between |= and ||=?
in thread What is the difference between |= and ||=?
$some_href->{id} ||= 0;Whether or not it's good style depends on what you intend to do.
Is that a good style?
The statement $some_href->{id} ||= 0; will assign 0 to the hash element if the hash element is anything that Perl evaluates as false, e.g., undef, 0, '0' or '' (the empty string).
The statement could be used to 'canonicalize' any false value to the numeric value of 0. If this is the intent of the statement, it is good style.
|
|---|