Topic: a question in converting a string array to int array (SmallNum)?
That doesn't work at all :
str = str.each { |i| i.to_i } # str is the array of strings
any suggestions please?
You are not logged in. Please login or register.
Rails Forum - Ruby on Rails Help and Discussion Forum » Ruby Programming » a question in converting a string array to int array (SmallNum)?
That doesn't work at all :
str = str.each { |i| i.to_i } # str is the array of strings
any suggestions please?
Because of this: in block you get a copy of each string in array and then you simply convert it to integer. str.each in your case returns initial array of strings. If you want to convert this array you should make something like this:
str = str.map { |i| i.to_i }or
str.map! { |i| i.to_i }Hosting provided by aTech Media