Skip to content

Commit 4872685

Browse files
committed
Adds reason for is required, refs #2632
1 parent 29d0a6a commit 4872685

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/Language/typesystem.pod6

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ methods on all public attributes of that class.
433433
Defined as:
434434
435435
multi sub trait_mod:<is>(Attribute $attr, :$required!)
436+
multi sub trait_mod:<is>(Parameter:D $param, :$required!)
436437
437438
Marks a class or roles attribute as required. If the attribute is not
438439
initialized at object construction time throws
@@ -452,6 +453,15 @@ L<X::Attribute::Required>.
452453
CATCH { default { say .^name => .Str } }
453454
# OUTPUT: «X::Attribute::Required => The attribute '$!attr' is required, but you did not provide a value for it.␤»
454455
456+
You can provide a reason why it's required as an argument to C<is required>
457+
458+
=for code :skip-test
459+
class Correct {
460+
has $.attr is required("it's so cool")
461+
};
462+
say Correct.new();
463+
# OUTPUT: «The attribute '$!attr' is required because it's so cool,␤but you did not provide a value for it.␤»
464+
455465
=head3 trait C<hides>
456466
457467
The trait C<hides> provides inheritance without being subject to

0 commit comments

Comments
 (0)