/Ruby 2.7

class Enumerator::Yielder



Public Instance Methods

to_proc() Show source
static VALUE
yielder_to_proc(VALUE obj)
    VALUE method = rb_obj_method(obj, sym_yield);

    return rb_funcall(method, idTo_proc, 0);

Returns a Proc object that takes an argument and yields it.

This method is implemented so that a Yielder object can be directly passed to another method as a block argument.

enum = Enumerator.new { |y|
  Dir.glob("*.rb") { |file|
    File.open(file) { |f| f.each_line(&y) }

Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.