V
Vetrivel Vetrivel
what is the Difference between loop and while in ruby ?
loop do
end
while 1
end
loop do
end
while 1
end
what is the Difference between loop and while in ruby ?
loop do
end
while 1
end
furthermore loop do has an implicit rescue clause for a StopIteration exceptionHi,
At Sat, 14 Feb 2009 15:03:03 +0900,
Vetrivel Vetrivel wrote in [ruby-talk:328175]:what is the Difference between loop and while in ruby ?
loop do
end
loop is a kernel method which takes a block. A block
introduces new local variable scope.
loop do
a = 1
break
end
p a #=> causes NameError
while 1
end
while doesn't.
while 1
a = 1
break
end
p a #=> 1
At Sat, 14 Feb 2009 15:03:03 +0900,
Vetrivel Vetrivel wrote in [ruby-talk:328175]:what is the Difference between loop and while in ruby ?
loop is a kernel method which takes a block. A block
introduces new local variable scope.
while doesn't.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.