Documentation for method lookup

Documentation for method lookup, assembled from the following types:

role Metamodel::MethodContainer

From Metamodel::MethodContainer

(Metamodel::MethodContainer) method lookup

method lookup(Metamodel::MethodContainer: $obj$name --> Method)

Returns the first matching method object of the provided $name or (Mu) if no method object was found. The search for a matching method object is done by following the mro of $obj. Note that lookup is supposed to be used for introspection, if you're after something which can be invoked you probably want to use 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)␤» 

class Metamodel::ClassHOW

From Metamodel::ClassHOW

(Metamodel::ClassHOW) method lookup

method lookup(Metamodel::ClassHOW:D: $obj$method-name --> Method)

Returns the first matching Method with the provided name or Nil. It is faster than .^can but does not provide a full list of all candidates.

say Str.^lookup('Int').perl# OUTPUT: «method Int (Str:D $: *%_) { #`(Method|39910024) ... }␤»