对于单个字符串,适用freeze
的解析器优化。
"foo" # => generated every time it is called
"foo".freeze # => generated only once
有没有办法按照使用%w
文字的方式创建一个解析器优化的冻结字符串数组?
%w[foo bar baz] # => each string is generated every time it is called
... # => an array of strings generated only once