Skip to content

Instantly share code, notes, and snippets.

@pimeys
Created September 17, 2015 15:24
Show Gist options
  • Save pimeys/1594c47253d131b66763 to your computer and use it in GitHub Desktop.
Save pimeys/1594c47253d131b66763 to your computer and use it in GitHub Desktop.
static VALUE
rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
{
int mod = 0, level = -1;
VALUE result, lv;
rb_scan_args(argc, argv, "01", &lv);
if (!NIL_P(lv)) level = NUM2INT(lv);
if (level == 0) return ary_make_shared_copy(ary);
result = flatten(ary, level, &mod);
OBJ_INFECT(result, ary);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment