Like fun, but with the purpose of calling an instance method on a specific object

namespace HH;

function inst_meth(
  string $meth_name,

This function can only be used on public methods; for private or protected methods, use a lambda instead.


 class C {
  public function isOdd(int $i): bool { return $i % 2 == 1; }
  private function filter(Vector<int> $data): Vector<int> {
    $callback = inst_meth($this, 'isOdd');
    return $data->filter($callback);

See also:


  • $instance Any class object.
  • string $meth_name

Return Values

  • A - callback which will call $method when invoked.