map!()
public
Invokes the block once for each element of
self, replacing the element with the value returned by
block. See also Enumerable#collect.
If no block is given, an enumerator is returned instead.
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;
}