+ 6

Is loop do in ruby same as do while loop in c++?

In c++ do while loop will execute the block atleast once even though the condition is false. Does loop do in ruby do the same thing

11th Apr 2017, 1:56 AM
Harshitha P N
4 Answers
+ 8
I dont think so... while x < 10 puts x is the same as while x < 10 loop do puts x... I belive.
11th Apr 2017, 10:19 AM
MrCoder
MrCoder - avatar
+ 6
@Supersebi3 Thats what I thought too, It is different from do while loops
11th Apr 2017, 11:19 AM
MrCoder
MrCoder - avatar
+ 5
loop do doesnt take any arguments, it just loops forever like while true
11th Apr 2017, 11:07 AM
Supersebi3
Supersebi3 - avatar
+ 5
loop is like these : for( ; ; ) { } while(true) { } do { } while(true) #All of these are infinite loops.
11th Apr 2017, 11:23 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar