Skip to content

Instantly share code, notes, and snippets.

@whylom
Created April 11, 2012 18:58
Show Gist options
  • Save whylom/2361395 to your computer and use it in GitHub Desktop.
Save whylom/2361395 to your computer and use it in GitHub Desktop.
Flavors of Ruby string interpolation
# 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