|(p1)
public
Set Union — Returns a new array by joining ary with
other_ary, excluding any duplicates and preserving the order from
the original array.
It compares elements using their #hash and
#eql? methods for efficiency.
[ "a", "b", "c" ] | [ "c", "d", "a" ]
See also Array#uniq.
Show source
static VALUE
rb_ary_or(VALUE ary1, VALUE ary2)
{
VALUE hash, ary3;
long i;
ary2 = to_ary(ary2);
hash = ary_make_hash(ary1);
for (i=0; i<RARRAY_LEN(ary2); i++) {
VALUE elt = RARRAY_AREF(ary2, i);
if (!st_update(RHASH_TBL_RAW(hash), (st_data_t)elt, ary_hash_orset, (st_data_t)elt)) {
RB_OBJ_WRITTEN(hash, Qundef, elt);
}
}
ary3 = rb_hash_values(hash);
ary_recycle_hash(hash);
return ary3;
}