Skip to content

Instantly share code, notes, and snippets.

@adambeynon
Created March 6, 2014 15:19
Show Gist options
  • Save adambeynon/9391955 to your computer and use it in GitHub Desktop.
Save adambeynon/9391955 to your computer and use it in GitHub Desktop.

Sending method no args

recv.foo
rb_send0(recv, 'foo');

function rb_send0(recv, mid) {
  if (recv == null) {
    return NIL_CLASS[mid](recv);
  }
  
  if (recv.$opal_methods) {
    return recv.$opal_methods[mid](recv);
  }
  
  if (typeof(recv[mid]) === "function") {
    return recv[mid].call(recv);
  }
  
  return recv[mid];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment