txt: ## lookup.md
  lookup
  
  Combined from primary sources listed below.
  
  # [In Metamodel::ClassHOW](#___top "go to top of document")[§](#(Metamodel::ClassHOW)_method_lookup "direct link")
  
  See primary documentation
  [in context](/type/Metamodel/ClassHOW#method_lookup)
  for **method lookup**.
  
  ```raku
  method lookup($obj, $method-name --> Method:D)
  ```
  
  Returns the first matching [`Method`](/type/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](/routine/defined). It is potentially faster than `.^can` but does not provide a full list of all candidates.
  
  ```raku
      say Str.^lookup('Int').raku; # OUTPUT: «method Int (Str:D $: *%_) { #`(Method|39910024) ... }␤»
  
      for <uppercase  uc> {
          Str.^lookup: $^meth andthen .("foo").say
              orelse "method `$meth` not found".say
      }
      # OUTPUT:
      # method `uppercase` not found
      # FOO
  
  ```
  
  # [In role Metamodel::MethodContainer](#___top "go to top of document")[§](#(role_Metamodel::MethodContainer)_method_lookup "direct link")
  
  See primary documentation
  [in context](/type/Metamodel/MethodContainer#method_lookup)
  for **method lookup**.
  
  ```raku
  method lookup($obj, $name --> Method)
  ```
  
  Returns the first matching [`Method`](/type/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](/type/Metamodel/C3MRO) 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](/routine/find_method) instead.
  
  ```raku
  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.
  