good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^5: Trouble with, or misunderstanding of, Types::Standard ArrayRef[elements] enforcement in Mooby tobyink (Canon) |
on May 03, 2019 at 13:23 UTC ( [id://1233318]=note: print w/replies, xml ) | Need Help?? |
$type->($value) is a live-or-die function rather than returning a boolean. It returns $value if it lives. Makes it easy to do something like:
$type->check($value) returns a boolean. Exporting an is_Topping (boolean) or assert_Topping (live or die) function will be faster because it will avoid overhead from things like overloading, method lookups, etc. Though what you've already got is unlikely to be a major bottleneck for your application, so I'd mostly say go with what you feel is more readable.
In Section
Seekers of Perl Wisdom
|
|