Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created October 25, 2012 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/3955113 to your computer and use it in GitHub Desktop.
Save havenwood/3955113 to your computer and use it in GitHub Desktop.
Hash#[] from Ruby hash.c
VALUE
rb_hash_aref(hash, key)
VALUE hash, key;
{
VALUE val;
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
return rb_funcall(hash, id_default, 1, key);
}
return val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment