map!()
public
Invokes the block once for each element of
self, replacing the element with the value returned by
block. See also Enumerable#collect.
a = [ "a", "b", "c", "d" ]
a.collect! {|x| x + "!" }
a
Show source
static VALUE
rb_ary_collect_bang(VALUE ary)
{
long i;
RETURN_ENUMERATOR(ary, 0, 0);
rb_ary_modify(ary);
for (i = 0; i < RARRAY_LEN(ary); i++) {
rb_ary_store(ary, i, rb_yield(RARRAY_PTR(ary)[i]));
}
return ary;
}