I have the following code in my controller:
@raw_data = ["124324/12", "345346/15"]
@data_set = []
@raw_data.each do |data|
holder = data.split("/")
holder.first.to_i
@data_set << holder
end
This returns the following
[["124324", "12"], ["345346", "15"]]
Why has it not converted the first element in each sub array to an integer. Please explain
Because
to_ireturns the converted value. It doesn’t do an in place conversion. This means that the value of the variable doesn’t change.