File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,29 @@ default accessor for the attribute will return a writable value.
111
111
CATCH { default { put .^name, ': ', .Str } };
112
112
# OUTPUT: «X::Assignment::RO: Cannot modify an immutable Any»
113
113
114
+ = head2 X < trait is built|trait,is built (Attribute) >
115
+
116
+ Defined as:
117
+
118
+ multi sub trait_mod:<is>(Attribute:D $a, :$built!)
119
+
120
+ By default, this trait allows setting up a I « private attribute » during object
121
+ construction via C « .new » . The same trait can be used to prevent setting up a
122
+ I « public attribute » via C « .new » by passing it the boolean value C « False » .
123
+
124
+ class Foo {
125
+ has $!bar is built; # same as `is built(True)`
126
+ has $.baz is built(False);
127
+
128
+ method bar {
129
+ $!bar
130
+ }
131
+ }
132
+
133
+ my $foo = Foo.new(bar => 1, baz => 2);
134
+ say $foo.bar; # «1»
135
+ say $foo.baz; # «Any»
136
+
114
137
= head1 Methods
115
138
116
139
The usual way to obtain an object of type C < Attribute > is by introspection:
You can’t perform that action at this time.
0 commit comments