# Print your name 10 times. # We can start off with a basic while loop. i = 1 while (i <= 10) puts( "Ben" ); i = (i + 1); end # Ruby uses a lot of Ranges. These are sets of values that go from # a start value to an end value. We can use a FOR loop to loop over # the ranges. for i in (1..10) puts( "Benjamin" ); end # We can also use ranges with iteration. (1..10).each{ puts( "B-Jamin" ) } # I am not sure if this creates a range, or is doing something else # more "special"; but, we can also use the Integer's upto() method # to iterate from one number to another. # # In this version, our iteration body is using do/end. This would # also work with the {..} approach; I'm just trying to get used to # the enormous number of ways in which you can execute code. 1.upto( 10 ) do |i| puts( "Big Ben" ); end # We can also use the times method to iteration from zero to n-1 # where n is our base value (NOTE: This one is a Married With # Children reference). 10.times{ puts( "Grand Master B" ); }