I didn't know how to get more than one input, and I found out that I was looking into it, so I'll record it. This time, it is the case where multiple elements are entered in one line.
The following input results are converted to integer type and output.
Standard input
1999 2000
input_line = gets.split(' ').map(&:to_i)
puts input_line
Output result
[1999, 2000]
"Split" splits an element and stores it in an array.
"Map" evaluates inside the block and replaces it with an array. In this case, it means that it is replaced with an integer type.
If you make a mistake, please point it out.
Recommended Posts