# Test the Ruby string class. # Code for 7/23: # Create two strings: a = "rabbit" b = String.new("raccoon") # Print lengths of strings: print a.length, " ", b.length, "\n" # Convert a to uppercase with nondestructive method: c = a.upcase print c, " ", a, "\n" # Convert a to uppercase with destructive method: a.upcase! print a, "\n" # Test if strings are equal: print a.eql?(b), " ", a.eql?(a), " ", a == b, " ", a == a, "\n" # Code for 7/25: # Insert string "abc" into b: b.insert(3, "abc") print b, "\n" # Find the index of the substring "coo": print b.index("coo"), "\n" # Test to_i method: d = "345" print d.to_i + 1, "\n" # Test replication operator: print a * 3, "\n" print (a + " ") * 3, "\n"