irb(main):001:0> a = %w(bird dog cat)
=> [“bird”, “dog”, “cat”]
irb(main):002:0>
Is there a command to get the same format when I display an array with a
program?
p (which is equivalent to puts foo.inspect)
Also, this code:
a1 = %w(cat dog bird)
puts a1
a2 = %w{john joe jim}
puts a2
[…]
seems to suggest that braces and parentheses are equivalent. Is that
the case?
You can use any non-alphanumeric character with %w (or %r or whatever).
It
won’t make a difference. Examples:
%w
%w_li la lo_
%w#chunky bacon#
%w)foo bar) # This one’s strange, I know.
etc.