MxyL MxyL - 11 months ago 77
Ruby Question

Ruby string substitution

Don't know what the term is called (substitution?), but in python if you type

num1 = 4
num2 = 2
print("Lucky numbers: %d %d" %(num1, num2))

You get "Lucky numbers: 4 2"

How do I do this in ruby?

Trying to do the above scenario, it works if I have one variable, but if I need to sub in multiple variables the parentheses aren't valid syntax.

num1 = 4  
num2 = 2  
print "Lucky numbers: %d %d" % [num1, num2]