P
Phillip Curry
[Note: parts of this message were removed to make it a legal post.]
I want to take an array of strings and convert each member to an integer.
array.to_i obviously doesn't work.
I tried array.each { |x| x = x.to_i } and that doesn't work either.
aray.each_index { |x| array[x] = array[x].to_i } works fine. I'm finding
that pretty much every time I try to use each, each_index works better. Why
doesn't each work here, is there anything I can do about it, and is there
anything in particular that each does better than each_index or should I
just drop it entirely?
thanks
phil
I want to take an array of strings and convert each member to an integer.
array.to_i obviously doesn't work.
I tried array.each { |x| x = x.to_i } and that doesn't work either.
aray.each_index { |x| array[x] = array[x].to_i } works fine. I'm finding
that pretty much every time I try to use each, each_index works better. Why
doesn't each work here, is there anything I can do about it, and is there
anything in particular that each does better than each_index or should I
just drop it entirely?
thanks
phil