From Python...
s = "hello, %s. Where is %s?" % ("John","Mary")
How do you do that in Ruby?
From Python...
s = "hello, %s. Where is %s?" % ("John","Mary")
How do you do that in Ruby?
Almost the same way:
irb(main):003:0> "hello, %s. Where is %s?" % ["John","Mary"]
=> "hello, John. Where is Mary?"
Actually almost the same
s = "hello, %s. Where is %s?" % ["John","Mary"]
The easiest way is string interpolation. You can inject little pieces of Ruby code directly into your strings.
name1 = "John"
name2 = "Mary"
"hello, #{name1}. Where is #{name2}?"
You can also do format strings in Ruby.
"hello, %s. Where is %s?" % ["John", "Mary"]
Remember to use square brackets there. Ruby doesn't have tuples, just arrays, and those use square brackets.