each()
public
Calls block once for each element
in self, passing that element as a parameter.
a = [ "a", "b", "c" ]
a.each {|x| print x, " -- " }
produces:
a -- b -- c --
Show source
/*
* call-seq:
* array.each {|item| block } -> array
*
* Calls <i>block</i> once for each element in <i>self</i>, passing that
* element as a parameter.
*
* a = [ "a", "b", "c" ]
* a.each {|x| print x, " -- " }
*
* produces:
*
* a -- b -- c --
*/
VALUE
rb_ary_each(ary)
VALUE ary;
{
long i;
RETURN_ENUMERATOR(ary, 0, 0);
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(RARRAY(ary)->ptr[i]);
}
return ary;
}