Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns a new Array containing all non-nil elements from self:
a = [nil, 0, nil, 1, nil, 2, nil]
a.compact # => [0, 1, 2]
 
               static VALUE
rb_ary_compact(VALUE ary)
{
    ary = rb_ary_dup(ary);
    rb_ary_compact_bang(ary);
    return ary;
}
            

Was this page useful?