Reputation: 13
Say some looks like below
def fun s1,s2
#code to process s1, s2
end
var1 = "value for s1"
var2 = "value for s2"
str_to_run = "fun '#{var1}', '#{var2}'"
eval str_to_run
My question is: are there any other way to compose string for dynamically run?
Upvotes: 1
Views: 60
Reputation: 118261
Just do use #public_send
.
str_to_run = public_send "fun", var1, var2
Upvotes: 2