Ruby Cheatsheet


Placeholder String Trick

Ruby has a trick for creating placeholders within a string and then populating the placeholders’ positions with an array of values.

VERSE = "On the %s day of Christmas my true love gave to me: %s."

VERSE % ["first", "a Partridge in a pair tree"]

The % inserts the array of values sequentially into the %s portions of the text

· ruby , cheatsheet