Created
November 5, 2013 03:16
-
-
Save 9cardinals/7313305 to your computer and use it in GitHub Desktop.
simple string interpolation example in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p "hello #{3}" | |
num = 5 | |
p "hello #{num}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.