V
Vin Raja
Hi All,
I have following lines
m=['a','b','c']
puts m.each_with_index{|v,i| i}
which output in:
I was expecting to see indexes, rather than values.
Am I overlooking some trivial nuance or what.
Basically i wanted to print index values while iterating an array at
some other project.
and "each_with_index" seemed very obvious for the task but for the
unexpected result.
Raja
I have following lines
m=['a','b','c']
puts m.each_with_index{|v,i| i}
which output in:
ruby try.rb a
b
c
Exit code: 0
I was expecting to see indexes, rather than values.
Am I overlooking some trivial nuance or what.
Basically i wanted to print index values while iterating an array at
some other project.
and "each_with_index" seemed very obvious for the task but for the
unexpected result.
Raja