Skip to content

Instantly share code, notes, and snippets.

@deepakdargade
Forked from revathskumar/array.rb
Last active February 25, 2017 13:24
Show Gist options
  • Select an option

  • Save deepakdargade/c93fa0c477814a289f18cfa7b009d68b to your computer and use it in GitHub Desktop.

Select an option

Save deepakdargade/c93fa0c477814a289f18cfa7b009d68b 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment