Before leaving the subject of strings, you’ll take a quick look at a few common string operations.
You can concatenate strings using
+ or just by placing a space between them. Here are three examples of string concatenation; in each case,
s is assigned the string “Hello world”:
s = "Hello " << "world" s = "Hello " + "world" s = "Hello " "world"
Note that when you use the
<< method, you can append Fixnum integers (in the range 0 to 255), in which case those integers are converted to the character with that character code. Character codes 65 to 90 are converted to the uppercase characters A to Z, 97 to 122 are converted to the lowercase a to z, and other codes are converted to punctuation, special ...