Sha256: 5c26f71876fb41e9499b6bac21c783f9b5064233595dfe8e9649b5b9f26f374b

Contents?: true

Size: 218 Bytes

Versions: 21

Compression:

Stored size: 218 Bytes

Contents

# http://snippets.dzone.com/posts/show/5119
class Array
  def map_with_index!
    each_with_index do |e, idx| self[idx] = yield(e, idx); end
  end

  def map_with_index(&block)
    dup.map_with_index!(&block)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
ruco-0.0.22 lib/ruco/core_ext/array.rb
ruco-0.0.21 lib/ruco/core_ext/array.rb
ruco-0.0.20 lib/ruco/core_ext/array.rb
ruco-0.0.19 lib/ruco/core_ext/array.rb
ruco-0.0.18 lib/ruco/core_ext/array.rb
ruco-0.0.17 lib/ruco/core_ext/array.rb
ruco-0.0.16 lib/ruco/core_ext/array.rb
ruco-0.0.15 lib/ruco/core_ext/array.rb
ruco-0.0.14 lib/ruco/core_ext/array.rb
ruco-0.0.13 lib/ruco/core_ext/array.rb
ruco-0.0.12 lib/ruco/core_ext/array.rb
ruco-0.0.11 lib/ruco/core_ext/array.rb
ruco-0.0.10 lib/ruco/core_ext/array.rb
ruco-0.0.9 lib/ruco/core_ext/array.rb
ruco-0.0.8 lib/ruco/core_ext/array.rb
ruco-0.0.7 lib/ruco/core_ext/array.rb
ruco-0.0.6 lib/ruco/core_ext/array.rb
ruco-0.0.5 lib/ruco/core_ext/array.rb
ruco-0.0.4 lib/ruco/core_ext/array.rb
ruco-0.0.2 lib/ruco/core_ext/array.rb