Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby array of strings

# Array of symbols
%i[address city state post_code country]
=> [:address, :city, :state, :post_code, :country]

# Array of strings
 %w[address city state postal country]
=> ["address", "city", "state", "postal", "country"]

# Array of interpolated symbols
postal_label = 'zip'
%I[address city state #{postal_label} country]
=> [:address, :city, :state, :zip, :country]

# Array of interpolated strings
%W[address city state #{postal_label} country]
=> ["address", "city", "state", "zip", "country"]
# Instead of %i[] you may use %i{} or %i() or %i!!
 
PREVIOUS NEXT
Tagged: #ruby #array #strings
ADD COMMENT
Topic
Name
5+6 =