Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active June 25, 2017 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/4bb9490a7da02f33c83257aad381925c to your computer and use it in GitHub Desktop.
Save dogbert17/4bb9490a7da02f33c83257aad381925c to your computer and use it in GitHub Desktop.
Attempt to document lookup
=head2 method lookup
method lookup(Metamodel::MethodContainer: $obj, $name --> Method)
Returns the first matching L<method|/type/Method> object of the provided C<$name>,
by following the L<mro|/type/Metamodel::C3MRO> of C<$obj>, or C<(Mu)> if no method
object was found. Note that C<lookup> is supposed to be used for introspection,
if you're after something which can be invoked you probably want to use
L<find_method|routine/find_method> instead.
say 2.5.^lookup("sqrt").perl: # OUTPUT: «method sqrt (Rat $: *%_) ...␤»
say Str.^lookup("BUILD").perl; # OUTPUT: «submethod BUILD (Str $: :$value = "", *%_ --> Nil) ...␤»
say Int.^lookup("does-not-exist"); # OUTPUT: «(Mu)␤»
@MasterDuke17
Copy link

"If no method object was not found", double negative

@dogbert17
Copy link
Author

Thx MasterDuke17, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment