Reputation:
I want to use variable insite %w{} but this is generating only string.
I have try with
a="hello",
b="world"
%w{a b}
But this is display ["a", "b"]
I want to display ["hello","world"]
Upvotes: 7
Views: 4346
Reputation: 38728
If you want to use variables you can use interpolation and the %W
variant
a = "hello"
b = "world"
pp %W{#{a} #{b} this is normal text} #=> ["hello", "world", "this", "is", "normal", "text"]
Upvotes: 18