Skip to content

Instantly share code, notes, and snippets.

@9cardinals
Created November 5, 2013 03:16
Show Gist options
  • Save 9cardinals/7313305 to your computer and use it in GitHub Desktop.
Save 9cardinals/7313305 to your computer and use it in GitHub Desktop.
simple string interpolation example in ruby
p "hello #{3}"
num = 5
p "hello #{num}"
@9cardinals
Copy link
Author

Notice the non-string values are contained inside of the #{}. You can also add more to the String after the #{ } syntax. The Ruby interpreter will run the code inside of the #{ } first and then return it to the outer String. This will ultimately return a String with all interpolated values accounted for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment