I see literal notation like %w[foo bar] being used all the time, but I dont see the benefit in using that over ["foo", "bar"]. Is it used as convention, or is this some performance/time benefit?
I see literal notation like %w[foo bar] being used all the time, but I
Share
In some cases it’s more readable. Compare these made-up examples:
While the third one is almost as readable as the first one, it performs worse (needs to allocate and populate array). The first two, on the other hand, are processed at parse time.