why
ErrorsCollection

why

Synthesised documentation from type/X/Attribute/Required

From type/X/Attribute/Required

See Original text in context

method why(--> Str:D)

Returns the reason why that attribute is required, and it will be included in the message if provided. That reason is taken directly from the is required trait.

my class Uses-required {
    has $.req is required("because yes")
};
my $object = Uses-required.new();                                  │
# OUTPUT: 
# «(exit code 1) The attribute '$!req' is required because because yes,␤ 
# but you did not provide a value for it.␤»