October 2006
Intermediate to advanced
888 pages
16h 55m
English
The append operator << can be used to append a string onto another string. It is “stackable” in that multiple operations can be performed in sequence on a given receiver.
str = "A" str << [1,2,3].to_s << " " << (3.14).to_s # str is now "A123 3.14"
If a Fixnum in the range 0..255 is specified, it will be converted to a character:
str = "Marlow" str << 101 << ", Christopher" # str is now "Marlowe, Christopher"
Read now
Unlock full access