Documentation for method lookup assembled from the following pages:

Class: Metamodel::ClassHOW §

From Metamodel::ClassHOW

(Metamodel::ClassHOW) method lookup §

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

Returns the first matching Method with the provided name. If no method was found, returns a VM-specific sentinel value (typically a low-level NULL value) that can be tested for with a test for definedness. It is potentially faster than .^can but does not provide a full list of all candidates.

    say Str.^lookup('Int').raku# OUTPUT: «method Int (Str:D $: *%_) { #`(Method|39910024) ... }␤» 
 
    for <upper-case  uc> {
        Str.^lookup: $^meth andthen .("foo").say
            orelse "method `$meth` not found".say
    }
    # OUTPUT: 
    # method `upper-case` not found 
    # FOO 

Role: Metamodel::MethodContainer §

From Metamodel::MethodContainer

(Metamodel::MethodContainer) method lookup §

method lookup($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").raku;      # OUTPUT: «method sqrt (Rat $: *%_) ...␤» 
say Str.^lookup("BUILD").raku;     # OUTPUT: «submethod BUILD (Str $: :$value = "", *%_ --> Nil) ...␤» 
say Int.^lookup("does-not-exist"); # OUTPUT: «(Mu)␤»

The difference between find_method and lookup are that find_method will use a default candidate for parametric roles, whereas lookup throws an exception in this case, and that find_method honors FALLBACK methods, which lookup does not.