Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do you use %w[] in rails?

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

like image 750
user3180 Avatar asked Dec 03 '22 23:12

user3180


1 Answers

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']
like image 86
jan.zikan Avatar answered Dec 24 '22 06:12

jan.zikan