So interpolation works like the following. You first need to have double quotes like using the “”‘s. Then inside of those double quotes you just add the # and then the {} which contains the block of code that you want to run. So in this case you have 2 assignments:
name = "James Kirk"
starship = "USS Enterprise"
Would result in you “interpolating” the variables in the string such as this:
what_you_want = "The captain of the #{starship} is #{name}"
Hope this helps! If not, please leave a comment and I’ll elaborate.
3
solved ruby expression for string interpolation [closed]