为什么常量插值不能在Ruby中使用百分比表示法

mce*_*ede 2 ruby string-interpolation

这不起作用:

FOOBAR = 'foobar'
%W{ FOOBAR }

output: ["FOOBAR"]
Run Code Online (Sandbox Code Playgroud)

但是,常量通过以下方式正确插值:

"#{FOOBAR}"
output: "foobar"
Run Code Online (Sandbox Code Playgroud)

Mar*_*pka 5

你在滥用%W文字.从书中:

%W - 插值的单词数组,由空格分隔

所以它与插值没有任何关系.