You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creates a new type from the metamodel, which we can proceed to build
119
+
120
+
my $type = Metamodel::ClassHOW.new_type(name => "NewType",
121
+
ver => v0.0.1,
122
+
auth => 'github:perl6' );
123
+
$type.HOW.add_method($type,"hey", method { say "Hey" });
124
+
$type.hey; # OUTPUT: «Hey»
125
+
$type.HOW.compose($type);
126
+
my $instance = $type.new;
127
+
$instance.hey; # OUTPUT: «Hey»
128
+
129
+
We add a single method by using L<Higher Order Workings|/language/mop#index-entry-syntax_HOW-HOW> methods, and then we can use that method directly as class method; we can then C<compose> the type, following which we can create already an instance, which will behave in the exact same way.
0 commit comments