Skip to content

Commit da962d2

Browse files
committed
Adds example for is default on attributes
The item in #2632 was already covered, but this add an illustrative example.
1 parent 1fc5dfb commit da962d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/Type/Attribute.pod6

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ argument of C<is default> will set the default item value or hash value.
3030
$c.a = Nil;
3131
say $c;
3232
# OUTPUT: «C.new(a => 666)␤C.new(a => 42)␤»
33+
class Foo {
34+
has @.bar is default(42) is rw
35+
};
36+
my $foo = Foo.new( bar => <a b c> );
37+
$foo.bar =Nil;
38+
say $foo; # OUTPUT: «Foo.new(bar => [42])␤»
3339
3440
=head2 X<Trait is required|trait,is required (Attribute)>
3541

0 commit comments

Comments
 (0)