File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,24 @@ class Journey {
184
184
}
185
185
= end code
186
186
187
+ Alternatively, you can omit the twigil, which will still create the private
188
+ attribute (with a C < ! > twigil), and will also create an alias that binds
189
+ the name (without the twigil) to that attribute. Thus, you can declare the
190
+ same class above with
191
+
192
+ = begin code
193
+ class Journey {
194
+ has $origin;
195
+ has $destination;
196
+ has @travelers;
197
+ has $notes;
198
+ }
199
+ = end code
200
+
201
+ If you declare the class like this, you can subsequently access the attributes
202
+ either with or without the twigil – e.g., C < $!origin > and C < $origin > refer to
203
+ same attribute.
204
+
187
205
While there is no such thing as a public (or even protected) attribute,
188
206
there is a way to have accessor methods generated automatically: replace the
189
207
C < ! > twigil with the C < . > twigil (the C < . > should remind you of a method
You can’t perform that action at this time.
0 commit comments