This is the code using while :
i = 0 num = 5 while i < num do puts "Inside the loop! i = #{i}" i += 1 end
This is the code using until :
i = 0 num = 5 until i > num do puts "Inside the loop! i = #{i}" i += 1 end
Can someone give an example of when you need to be preferred over others? There is no reason for me to have until and while if they do the same. In my opinion, it is for this reason that other programming languages โโdo not have both.
source share