Skip to content

Instantly share code, notes, and snippets.

@revathskumar
Last active February 25, 2017 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save revathskumar/4673179 to your computer and use it in GitHub Desktop.
Save revathskumar/4673179 to your computer and use it in GitHub Desktop.
template = "Price of the %s is Rs. %f."
# %s - string, %f - float and %d - integer
p template % ["apple", 70.00]
# prints Price of the apple is Rs. 70.000000.
template = "Price of the %{product} is Rs. %{price}."
p template % {product:"apple", price:70.00}
# prints Price of the apple is Rs. 70.0.
product = "apple"
cost = "70.00"
p "Price of the #{product} is Rs. #{cost}."
# prints Price of the apple is Rs. 70.00.

"Price of the product is Rs. cost."

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