Class: Object

Inherits:
BasicObject
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#to_enum(method = :each, *args) ⇒ Object #enum_for(method = :each, *args) ⇒ Object

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)


46
47
48
# File 'enumerator.c', line 46

static VALUE
obj_to_enum(obj, enum_args)
VALUE obj, enum_args;

#to_enum(method = :each, *args) ⇒ Object #enum_for(method = :each, *args) ⇒ Object

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)


46
47
48
# File 'enumerator.c', line 46

static VALUE
obj_to_enum(obj, enum_args)
VALUE obj, enum_args;