method required
Documentation for method required
assembled from the following types:
class Attribute
From Attribute
(Attribute) method required
Defined as:
method required(Attribute:D: --> Any:D)
Returns 1
for attributes that have the "is required" trait applied, or Mu
if the attribute did not have that trait applied. If the "is required" trait is applied with a string, then that string will be returned instead of 1
.
class Library { has $.address is required; has @.new-books is required("we always need more books"); } my $addr = Library.^attributes(:local)[0]; my $new-books = Library.^attributes(:local)[1]; say $addr.required; # OUTPUT: «1» say $new-books.readonly; # OUTPUT: «"we always need more books"»