method
enum_with_index
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
v1_8_7_72 -
Show latest stable
-
1 note -
Class: Enumerable
- 1_8_6_287 (0)
- 1_8_7_72 (28)
- 1_8_7_330 (0)
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
enum_with_index()
public
Calls block with two arguments, the item and its index, for each item in enum.
hash = Hash.new %w(cat dog wombat).each_with_index {|item, index| hash[item] = index } hash #=> {"cat"=>0, "wombat"=>2, "dog"=>1}
Register or
log in
to add new notes.
yonosoytu -
August 23, 2008
![Default_avatar_30](https://www.gravatar.com/avatar/49b6123803e4f327144e991daab62f77?default=http://apidock.com/images/default_avatar_30.png&size=30)
0 thanks
Needs requiring 'enumerator' to work
This method needs that you
require 'enumerator'
for this method to be available.