-
-
Save Altai-man/049f7bf436d348a456ead66f7929a9f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an enum | |
my $new-enum = Metamodel::EnumHOW.new_type(name => 'A', base_type => Int); | |
$new-enum.^compose_repr; | |
# Create a value | |
my $value = $new-enum.new(2); | |
$value.^add_method('key', method { 'Two' }); | |
$value.^add_method('value', method { 2 }); | |
# Add a value and compose the enum | |
$new-enum.^add_enum_value($value); | |
$new-enum.^compose; | |
# Test part | |
say $new-enum.^name; # A | |
say $value.^name; # A | |
say $value ~~ $new-enum; # Has to be True => False | |
say $new-enum ~~ $value; # Has to be False => False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment