O'Reilly logo
  • Sean Bolak thinks this is interesting:

Double-quoted strings can include arbitrary Ruby expressions delimited by #{ and }. The value of the expression within these delimiters is converted to a string (by calling its to_s method, which is supported by all objects). The resulting string is then used to replace the expression text and its delimiters in the string literal. This substitution of expression values into strings is usually called string interpolation.


Cover of The Ruby Programming Language


String interpolation is achievable on ALL objects in ruby by using the to_s method or the syntactic sugar version of "#{value} in string"