Just map the array to integers:
@land << @input[x].split(/\s/).map(&:to_i)
side note
If you want to get the average value of a string, you can do the following:
values = @input[x].split(/\s/).map(&:to_i) @land << values.inject(0.0) {|sum, item| sum + item} / values.size
or use the following, as Marc-AndrΓ© has kindly indicated in the comments:
values = @input[x].split(/\s/).map(&:to_i) @land << values.inject(0.0, :+) / values.size
source share