Subject: | Accessor when called to set a value, ignores certain values. |
If Example::foo is an accessor generated by Object::Nano, then:
my $obj = Example->new(foo => 2);
$obj->foo('');
$obj->foo(0);
$obj->foo(undef);
$obj->foo('0');
say $obj->foo; # says 2
Basically Object::Nano ignores any value that Perl treats as false.
Other modules that generate accessors, such as Moose, Object::Tiny::RW,
etc, do not suffer from this problem. The trick is to replace this:
if ($val)
with this:
if (@_ == 2)