Created
December 14, 2014 02:59
-
-
Save preaction/566e2f27954f57d56a74 to your computer and use it in GitHub Desktop.
Attribute value after clearer is called differs between lazy and non-lazy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
package FooMoo; | |
use Moo; | |
has foo => ( | |
is => 'rw', | |
default => sub { 'foo' }, | |
clearer => 1, | |
); | |
has bar => ( | |
is => 'rw', | |
default => sub { 'bar' }, | |
lazy => 1, | |
clearer => 1, | |
); | |
} | |
use strict; | |
use warnings; | |
use feature ':5.10'; | |
my $foo = FooMoo->new; | |
say "foo: " . $foo->foo; | |
$foo->foo( "BAZINGA" ); | |
say "foo after set: " . $foo->foo; | |
$foo->clear_foo; | |
say "foo after clear: " . $foo->foo; | |
say "bar: " . $foo->bar; | |
$foo->bar( "BAZINGA" ); | |
say "bar after set: " . $foo->bar; | |
$foo->clear_bar; | |
say "bar after clear: " . $foo->bar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment