Skip to main content
deleted 33 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174

Ruby has Enumerator#with_index(offset = 0). To, so first convert the array to an enumerator, use using Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 

Ruby has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 

Ruby has Enumerator#with_index(offset = 0), so first convert the array to an enumerator using Object#to_enum or Array#map:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 
deleted 9 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174

Ruby >= 1.9.3 has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 

Ruby >= 1.9.3 has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 

Ruby has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 
added 137 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174

Ruby >= 1.9.3 has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enumObject#to_enum or Array#mapArray#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 

Ruby >= 1.9.3 has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 

Ruby >= 1.9.3 has Enumerator#with_index(offset = 0). To convert the array to an enumerator, use Object#to_enum or Array#map, whatever feels more declarative to you:

[:a, :b, :c].map.with_index(2).to_a #=> [[:a, 2], [:b, 3], [:c, 4]] 
deleted 83 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
added 18 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
deleted 14 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
deleted 4 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
deleted 3 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
added 7 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
deleted 4 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
added 4 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
deleted 16 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
added 39 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
added 43 characters in body
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading
Source Link
tokland
  • 68.2k
  • 13
  • 151
  • 174
Loading