File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ methods on all public attributes of that class.
433
433
Defined as:
434
434
435
435
multi sub trait_mod:<is>(Attribute $attr, :$required!)
436
+ multi sub trait_mod:<is>(Parameter:D $param, :$required!)
436
437
437
438
Marks a class or roles attribute as required. If the attribute is not
438
439
initialized at object construction time throws
@@ -452,6 +453,15 @@ L<X::Attribute::Required>.
452
453
CATCH { default { say .^name => .Str } }
453
454
# OUTPUT: «X::Attribute::Required => The attribute '$!attr' is required, but you did not provide a value for it.»
454
455
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
+
455
465
= head3 trait C < hides >
456
466
457
467
The trait C < hides > provides inheritance without being subject to
You can’t perform that action at this time.
0 commit comments