Class | Object
In: |

### Methods

enum_for to_enum

### Public Instance methods

obj.to_enum(method = :each, *args)
obj.enum_for(method = :each, *args)

Returns Enumerable::Enumerator.new(self, method, *args).

e.g.:

       str = "xyz"

       enum = str.enum_for(:each_byte)
       a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]

       # protects an array from being modified
       a = [1, 2, 3]
       some_method(a.to_enum)

[Source]

    /*
     *  call-seq:
     *    obj.to_enum(method = :each, *args)
     *    obj.enum_for(method = :each, *args)
     *
     *  Returns Enumerable::Enumerator.new(self, method, *args).
     *
     *  e.g.:
     *     str = "xyz"
     *
     *     enum = str.enum_for(:each_byte)
     *     a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
     *
     *     # protects an array from being modified
     *     a = [1, 2, 3]
     *     some_method(a.to_enum)
     *
     */
    static VALUE
    obj_to_enum(obj, enum_args)
        VALUE obj, enum_args;
    {
        rb_ary_unshift(enum_args, obj);

        return rb_apply(rb_cEnumerator, id_new, enum_args);
    }

obj.to_enum(method = :each, *args)
obj.enum_for(method = :each, *args)

Returns Enumerable::Enumerator.new(self, method, *args).

e.g.:

       str = "xyz"

       enum = str.enum_for(:each_byte)
       a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]

       # protects an array from being modified
       a = [1, 2, 3]
       some_method(a.to_enum)

[Source]

    /*
     *  call-seq:
     *    obj.to_enum(method = :each, *args)
     *    obj.enum_for(method = :each, *args)
     *
     *  Returns Enumerable::Enumerator.new(self, method, *args).
     *
     *  e.g.:
     *     str = "xyz"
     *
     *     enum = str.enum_for(:each_byte)
     *     a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
     *
     *     # protects an array from being modified
     *     a = [1, 2, 3]
     *     some_method(a.to_enum)
     *
     */
    static VALUE
    obj_to_enum(obj, enum_args)
        VALUE obj, enum_args;
    {
        rb_ary_unshift(enum_args, obj);

        return rb_apply(rb_cEnumerator, id_new, enum_args);
    }

[Validate]