Skip to content

Commit 9793f64

Browse files
committed
mixed in a self into the attribute default example
1 parent 774d9bd commit 9793f64

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

doc/Language/objects.pod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ destination. To change this you can provide a default value or make
180180
sure that it is provided by marking it with L<is required>.
181181
182182
class Journey {
183-
has $.origin is required; # error if origin is not provided
184-
has $.destination = 'Orlando'; # if not provided set to Orlando
183+
# error if origin is not provided
184+
has $.origin is required;
185+
# set the destination to Orlando as default (unless that is the origin!)
186+
has $.destination = self.origin eq 'Orlando' ?? 'Kampala' !! 'Orlando';
185187
has @!travellers;
186188
has $.notes is rw;
187189
}

0 commit comments

Comments
 (0)