_ is the name of the variable, just like any other variable name (e.g. i ).
In Ruby, it is customary to use _ as the variable name or the prefix variable name with _ (for example, _i ) as an indication that you do not plan to use this variable in the future.
In your example, each_with_index two values ββat each iteration step: the current element and the current index.
each_with_index { |_, i| i.even? }
The author of the code should have named both values, but decided to use the variable name _ to indicate that they do not care about the current value, only about the current index.
spickermann
source share