End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Enumerator::Lazy#_enumerable_map
_enumerable_map
enumerator.c
View on GitHub ↗
static VALUE
lazy_map(VALUE obj)
{
if (!rb_block_given_p()) {
rb_raise(rb_eArgError, "tried to call lazy map without a block");
}
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_map_funcs);
}
Alias of #map
Like Enumerable#map, but chains operation to be lazy-evaluated.
Example
(1..Float::INFINITY).lazy.map {|i| i**2 } #=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9]
See also
#map
#_enumerable_grep_v
#_enumerable_reject
#_enumerable_grep
also in
4.0 · 3.4 · 3.3 · 3.1 · 3.0