range1 = 1..5 # from 1 to 5 inclusive range2 = Range.new(4, 10) # from 4 to 10 inclusive range3 = 'a'..'z' # from a to z inclusive range4 = 1...10 # from 1 to 10 excluding the last number (1 to 9) # print the ranges for example puts "[ #{range1.to_a.join( ', ' )} ]" puts "[ #{range2.to_a.join( ', ' )} ]" puts "[ #{range3.to_a.join( ', ' )} ]" puts "[ #{range4.to_a.join( ', ' )} ]" # iterating with ranges range1.each do |x| puts x end