Problem in loop do

A

Amir Ebrahimifard

Hi
please explain me with example in "loop do" , diffrence between "redo"
and "next".
tnx
 
R

Robert Klemme

please explain me with example in "loop do" , diffrence between "redo"
and "next".

Why don't you just write a small program and test it out for yourself?

Cheers

robert
 
A

Amir Ebrahimifard

Robert said:
Why don't you just write a small program and test it out for yourself?

Cheers

robert

I wrote a small program , and I test for myself but the result for
"next" and "redo" was same.
now please help me .
 
B

Bob Smith

Amir said:
I wrote a small program , and I test for myself but the result for
"next" and "redo" was same.
now please help me .

I've not been visiting here for very long, but I suspect people will be
quicker/more inclined to help if you provide the program you've created
to test the issue/question.

Play with the following code -- run it and see what it does... uncomment
the "next if i < 3" line, run it, and see what it does... recomment the
"next" line, uncomment the "redo" line, run it, and see what it does.

for i in 1..5
puts 'current value of i is: ' + i.to_s
#next if i < 3;
#redo if i < 3;
puts 'end of loop and i is: ' + i.to_s
end


Additionally, a quick Google search of "ruby redo next" will turn up
this link:

http://www.tutorialspoint.com/ruby/ruby_loops.htm
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top