Represent a type without any additional features
class RakuAST::Type::Enum { }
The RakuAST::Type::Enum class represents an enum specification.
RakuAST::Type::Enum object is typically created when parsing Raku Programming Language code. So most developers will only need to know how to introspect the objects created.
say $enum.name; # RakuAST::Name.from-identifier("Foo")
Returns the L<RakuAST::Name>|/type/RakuAST::Name object of this RakuAST::Type::Enum object.
say $enum.of; # RakuAST::Type::Simple.from-identifier("Int")
Returns the RakuAST::Type object of this RakuAST::Type::Enum to which the enum values are constrained.
say $enum.scope; # my
Returns the scope of the RakuAST::Type::Enum object as a string. Usually "our", but can also be "my" or "anon".
dd $enum.term; # <a b c>
Returns the RakuAST::Expression object that represents the names and values of this enum.
dd $enum.traits.head; # of Str
Returns a (possibly empty) list of RakuAST::Trait object that were applied to the enum.
There is only one way to create a RakuAST::Type::Enum object.
my $enum = RakuAST::Type::Enum.new(
scope => "my",
name => RakuAST::Name.from-identifier("Foo"),
of => RakuAST::Type::Simple.from-identifier("Int"),
traits => (
RakuAST::Trait::Of.new(
RakuAST::Type::Simple.from-identifier("Str")
),
),
term => RakuAST::QuotedString.new(
processors => <words val>,
segments => (
RakuAST::StrLiteral.new("a b c"),
)
)
);
dd $enum; # my Int enum Foo <a b c>
Creates a RakuAST::Type::Enum object from the given named arguments.