note
tobyink
<p>I believe a tied hash can override how it behaves in scalar context, so that an empty hash can return true and a non-empty hash can return false.</p>
<p>An overloaded object can do various tricky things with regards to how it behaves as a boolean. For example, it could die.</p>
<code>
if ($x || $y) {
say "Something was true. What was it?";
say '$x' if $x;
say '$y' if $y;
}
else {
say "Neither was true.";
}
</code>
<p>It is possible for this to print "Something was true?" but not tell you what was true. This is because $x or $y could be an overloaded object returning true or false at random each time they are checked.</p>
<div class="pmsig"><div class="pmsig-757127">
<small><a href="http://toby.ink/">toby döt ink</a></small>
</div></div>
11110557
11110571