34,333
edits
Changes
→The Ruby upto Method
Alternatively, we could achieve identical behavior using the ''upto'' method, passing the value to which we want the loop to run as an argument to the method:
<pre>
5.upto(10) do
puts "hello"
end
</pre>
If we so desired, we could shorten this to a single line of code:
<pre>