#output will display nil x = x + 1 while x < 10 #output will display 10 puts x #output nil x = x - 1 until x == 1 #output 1 puts x #output will print 2 - 10 while x < 10 x = x + 1 puts x end
Looking at the above code we can notice some aspects of ruby. The first block iterated through while x was less than 10 yet displayed 10. The second block of code subtracted 1 until x equaled 1. Finally the while loop displayed the numbers:
Though this is not a traditional tutorial using detailed explanation, the above snippets show the basics of making decisions that are straightforward. I will be posting more examples in the future.
Edited by Roger, 06 January 2011 - 12:00 PM.