Home > Articles > Programming > Ruby

  • Print
  • + Share This
This chapter is from the book

2.17 Appending an Item onto a String

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"
  • + Share This
  • 🔖 Save To Your Account