The operation #{ } appears to be so fundamental that my Ruby book completely skips its definition. Can someone provide an explanation?
The operation #{ } appears to be so fundamental that my Ruby book completely
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why This Is a Good Question
This is a tough question to Google for unless you know the right search terms. The
#{}operator technically performs expression substitution inside a string literal.The Answer
The
#{}literal is the operator used for interpolation inside double-quoted strings the same way that the backticks or$()construct would be used in Bash. From a practical point of view, the expression inside the literal is evaluated, and then the entire#{}expression (including both the operator and the expression it contains) is replaced in situ with the result.Related Links