4 ms·
Ruby has an interesting syntax for defining arrays of literal values. irb(main):001:0> sections = %w(one two three) => ["one", "two", "three"]
by allknowingfrog 4y ago
Ruby has an interesting syntax for defining arrays of literal values.
irb(main):001:0> sections = %w(one two three)
=> ["one", "two", "three"]
- pmontra 4y agoI know and it works on multiple lines too. However I never use it. Requirements change, refactoring happens, one of those literals becomes an interpolated string and all of a sudden I have to rewrite all the array. Furthermore %w() is just not nice to look at IMHO.