Represent a type without any additional features
class RakuAST::Type::Subset { }
The RakuAST::Type::Subset class represents an enum specification.
RakuAST::Type::Subset 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 $subset.is-coercive; # True or False
The is-coercive method returns whether the "of" type is coercive.
say $subset.name; # RakuAST::Name.from-identifier("Foo")
Returns the L<RakuAST::Name>|/type/RakuAST/Name object of this RakuAST::Type::Subset object.
say $subset.of; # RakuAST::Type::Simple.from-identifier("Int")
Returns the RakuAST::Type object of this RakuAST::Type::Subset to which the enum values are constrained.
say $subset.scope; # my
Returns the scope of the RakuAST::Type::Subset object as a string. Usually "our", but can also be "my" or "anon".
dd $subset.traits; # ()
Returns a (possibly empty) list of RakuAST::Trait object that were applied to the enum.
dd $subset.where; # * %% 2
Returns the RakuAST::Expression object that represents the names and values of this enum.
There is only one way to create a RakuAST::Type::Subset object.
my $subset = RakuAST::Type::Subset.new(
scope => "my",
name => RakuAST::Name.from-identifier('Foo'),
of => RakuAST::Type::Simple.from-identifier('Int'),
where => RakuAST::ApplyInfix.new(
left => RakuAST::Term::Whatever.new,
infix => RakuAST::Infix.new('%%'),
right => RakuAST::IntLiteral.new(2)
),
);
dd $subset; # my Int subset Foo where * %% 2
Creates a RakuAST::Type::Subset object from the given named arguments.