Module: Enumerable

Included in:
Enumerator
Defined in:
(unknown)

Defined Under Namespace

Classes: Enumerator

Instance Method Summary collapse

Instance Method Details

#each_cons(n) { ... } ⇒ Object

Iterates the given block for each array of consecutive elements.

e.g.: (1..10).each_cons(3) {|a| p a} # outputs below [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 6] [5, 6, 7] [6, 7, 8] [7, 8, 9] [8, 9, 10]

Yields:

  • []



174
175
176
# File 'enumerator.c', line 174

static VALUE
enum_each_cons(obj, n)
VALUE obj, n;

#each_slice(n) { ... } ⇒ Object

Iterates the given block for each slice of elements.

e.g.: (1..10).each_slice(3) {|a| p a} # outputs below [1, 2, 3] [4, 5, 6] [7, 8, 9] [10]

Yields:

  • []



102
103
104
# File 'enumerator.c', line 102

static VALUE
enum_each_slice(obj, n)
VALUE obj, n;

#enum_cons(n) ⇒ Object

Returns Enumerable::Enumerator.new(self, :each_cons, n).



196
197
198
# File 'enumerator.c', line 196

static VALUE
enumerator_enum_cons(obj, n)
VALUE obj, n;

#enum_slice(n) ⇒ Object

Returns Enumerable::Enumerator.new(self, :each_slice, n).



129
130
131
# File 'enumerator.c', line 129

static VALUE
enumerator_enum_slice(obj, n)
VALUE obj, n;

#enum_with_indexObject

Returns Enumerable::Enumerator.new(self, :each_with_index).



62
63
64
# File 'enumerator.c', line 62

static VALUE
enumerator_enum_with_index(obj)
VALUE obj;