S
Sam Sungshik Kong
Hello!
I am studying Ruby and have been using Python.
I apologize for my negligence not to check out the whole document first.
What is the equivalent of the following Python's expressions?
s = "My name is %s and my age is %d." % ("Sam", 34)
or
s = "My name is %(name)s and my age is %(age)d." % {"name": "Sam", "age":
34}
or
format = "My name is %(name)s and my age is %(age)d."
di = {"name": "Sam", "age": 34}
s = format % di
I know that ruby has "#{name}" expression.
But that requires a variable named "name" in advance.
I want to bind the format string and data later.
What is the closest thing in ruby?
I find the python expression quite useful.
Thanks.
Sam
I am studying Ruby and have been using Python.
I apologize for my negligence not to check out the whole document first.
What is the equivalent of the following Python's expressions?
s = "My name is %s and my age is %d." % ("Sam", 34)
or
s = "My name is %(name)s and my age is %(age)d." % {"name": "Sam", "age":
34}
or
format = "My name is %(name)s and my age is %(age)d."
di = {"name": "Sam", "age": 34}
s = format % di
I know that ruby has "#{name}" expression.
But that requires a variable named "name" in advance.
I want to bind the format string and data later.
What is the closest thing in ruby?
I find the python expression quite useful.
Thanks.
Sam