class RakuAST::Literal { }
The RakuAST::Literal class represents a literal value (such as `0` or `"foo"). It also serves as a base class for specific literal values:
RakuAST::IntLiteral- literalIntvalueRakuAST::NumLiteral- literalNumvalueRakuAST::StrLiteral- literalStrvalueRakuAST::RatLiteral- literalRatvalueRakuAST::ComplexLiteral- literalComplexvalueRakuAST::VersionLiteral- literalVersionvalue
Object introspection§
RakuAST::Literal objects are typically created when parsing Raku Programming Language code. So most developers will only need to know how to introspect the objects created.
These introspection methods are available (in alphabetical order):
value§
say $literal.value;
The value method returns the value it is representing.
Object creation§
There is one way to create a RakuAST::Literal object.
from-value§
my $literal = RakuAST::Literal.from-value(42); say $literal.^name; # RakuAST::IntLiteral
Creates a RakuAST::Literal object from the given value. Note that for some core types, specialized subclasses will be returned:
Intvalue ->RakuAST::IntLiteralNumvalue ->RakuAST::NumLiteralStrvalue ->RakuAST::StrLiteralRatvalue ->RakuAST::RatLiteralComplexvalue ->RakuAST::ComplexLiteralVersionvalue ->RakuAST::VersionLiteral
In all other cases a RakuAST::Literal object will be returned.