"hello"
is printed by puts
only three times. It is supposed to be printed six times, isn't it?
i = 0
j = 0
while(i != 2)
while(j != 3)
puts "hello"
j += 1
end
i += 1
end
|
||||
You have to set
Better is -
|
|||||
|
It may be easier for you if you work with loop {} - even though you have to keep track of the counter yourself, I find it much easier to understand instantly than using while, or x.times which also works fine. |
|||
|
for
andwhile
loops. For example:2.times { 3.times { puts "hello" } }
is equivalent to your code. – Daniël Knippers May 31 at 8:06