In creating a CLI bank challenge for my SheNomads Mentorship program, I found out about a RuboCop error surrounding the use of Array Literals, when referring to an Array of Words.

Apparently, there’s ‘Percent Notation’, which is preferred to the literal array syntax, as mentioned in Batssov’s Ruby-Style-Guide, the source of RuboCop’s preferences. When you use Array literal you get this warning:

'Use `%w` or `%W` for array of words'

Percent Notation lets you “stringify” a set of characters, separated and returned as a certain object, depending on the modifier.

# using Array literal syntax:
['January', 'February', 'June', 'July'].include?('September') #=> false

# using % notation:
%w[January February June July].include?('September') #=> false

There was an interesting discussion on the topic, over at the RuboCop github repo, and the person who authored the issue had a lot of thoughts about it, that helped to clarify it’s use.