Created
April 11, 2012 18:58
-
-
Save whylom/2361395 to your computer and use it in GitHub Desktop.
Flavors of Ruby string interpolation
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
# First, some variables! | |
a, b = %w(foo bar) | |
# Good old-fashioned string interpolation. | |
"#{a} is not #{b}" #=> "foo is not bar" | |
# Today, I learned that this craziness works! | |
"%s is not %s" % [a, b] #=> "foo is not bar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment