Richard Richard - 3 months ago 6
Ruby Question

Why do you use %w[] in rails?

Why would you ever use %w[] considering arrays in Rails are type-agnostic?

Answer

This is the most efficient way to define array of strings, because you don't have to use quotes and commas.

%w(abc def xyz)

Instead of

['abc', 'def', 'xyz']