How to use a variable inside% w {}

I want to use the variable insite% w {}, but this only generates a string.

I tried

a="hello", b="world" %w{ab} 

But this display ["a", "b"] I want to display ["hello", "world"]

+5
source share
1 answer

If you want to use variables, you can use interpolation and the %W option

 a = "hello" b = "world" pp %W{#{a} #{b} this is normal text} #=> ["hello", "world", "this", "is", "normal", "text"] 
+13
source

Source: https://habr.com/ru/post/1482326/


All Articles