Heads up: This description was created by AI and might not be 100% accurate.

percent_expression.rb

This Ruby code snippet demonstrates the creation of arrays from strings and symbols. Specifically, it shows how %w, %W, %i, and %I operators construct arrays containing strings, words, integers, and symbols, respectively, with string interpolation included when using the %W and %I operators.

Ruby code snippet

str='ruby'
#=> "ruby"

%w(a b c "#{str}")
#=> ["a", "b", "c", "\"\#{str}\""]
%W(a b c "#{str}")
#=> ["a", "b", "c", "\"ruby\""]

%i(a b c "#{str}")
#=> [:a, :b, :c, :"\"\#{str}\""]
%I(a b c "#{str}")
#=> [:a, :b, :c, :"\"ruby\""]

Executed with Ruby 3.4.5.