Skip to content

Instantly share code, notes, and snippets.

@ryanlecompte
Created April 25, 2012 04:15
Show Gist options
  • Save ryanlecompte/2486295 to your computer and use it in GitHub Desktop.
Save ryanlecompte/2486295 to your computer and use it in GitHub Desktop.
[1] pry(main)> show-method Array#dup
From: object.c in Ruby Core (C Method):
Number of lines: 14
Owner: Kernel
Visibility: public
VALUE
rb_obj_dup(VALUE obj)
{
VALUE dup;
if (rb_special_const_p(obj)) {
rb_raise(rb_eTypeError, "can't dup %s", rb_obj_classname(obj));
}
dup = rb_obj_alloc(rb_obj_class(obj));
init_copy(dup, obj);
rb_funcall(dup, id_init_dup, 1, obj);
return dup;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment