I can call ^methods
on an object and list the method names I can call:
my $object = 'Camelia';
my @object_methods = $object.^methods;
@object_methods.map( { .gist } ).sort.join("\n").say;
^methods
returns a list which I store in @object_methods
, then later I transform that list of method thingys by calling gist
on each one to get the human-sensible form of that method thingy.
But, the ^
in ^methods
is an implied .HOW
, as show at the end of the object documentation this should work too:
my $object = 'Camelia';
my @object_methods = $object.HOW.methods;
But, I get an error:
Too few positionals passed; expected 2 arguments but got 1
in any methods at gen/moar/m-Metamodel.nqp line 490
in block <unit> at...
And, for what it's worth, this is an awful error message for a language that's trying to be person-friendly about that sort of thing. The file m-Metamodel.nqp isn't part of my perl6 installation. It's not even something I can google because, as the path suggests, it's something that a compilation generates. And, that compilation depends on the version.