Method: Enumerable#collect_with_index

Defined in:
lib/xqsr3/extensions/enumerable/collect_with_index.rb

#collect_with_index(base = 0) ⇒ Object

Two-parameter #collect, where the second parameter is a #base-based index, which increments by 1 for each enumerated element.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/xqsr3/extensions/enumerable/collect_with_index.rb', line 57

def collect_with_index(base = 0)

	a = []

	self.each_with_index do |element, index|

		a.push yield(element, base + index)
	end

	a
end