# Test the String class. # This code is a little different than what we did in class. s = String.new("elephant") t = "antelope" print s, "\n" print "#{s.length} #{t.length}\n" print s.upcase, "\n" print s.index("ant"), "\n" print s.reverse, "\n\n" # Test the time class. t = Time.now print "#{t.mon}/#{t.day}/#{t.year % 1000}\n" print t.dst?, " ", t.wday, " ", t.to_i, "\n" # Test the array class. a = [34, 54, 76, 23, 11, 29] print "#{a[3]} #{a[5]} #{a.length}\n" # Iterate over elements x of a. a.each do |x| print x, " " end print "\n" b = a.sort # Change preceding line to b = a.sort! # What difference does the ! make? a.each do |x| print x, " " end print "\n" b.each do |x| print x, " " end print "\n"