Richard Richard - 1 year ago 54
Ruby Question

Why do you use %w[] in rails?

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

Answer Source

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']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download