3 ms·
Not every rule has a reason, some of it is just "because style guide" and if you try to look up the rationale there, you'll find none. Classic example is Perl
by 22c 7y ago
Not every rule has a reason, some of it is just "because style guide" and if you try to look up the rationale there, you'll find none.
Classic example is Perl style %w(literal arrays) vs ['traditional', 'arrays'].
> Prefer `%w` to the literal array syntax when you need an array of
strings
Which was introduced[1] into the style guide nearly 9 years ago with practically no reasoning. Prefer `%w` because why exactly?
[1] https://github.com/rubocop-hq/ruby-style-guide/commit/b27eff1b2ca6ee7502bb0c53afec4f25ae154a19 https://github.com/rubocop-hq/ruby-style-guide/commit/b27eff...
- hirundo 7y agoI prefer the brackets to parens because it makes it more clear at a glance that the result is an array.
- block_dagger 7y agoShorter. Different code coloring. I prefer %w where possible with or without Rubocop.