Array of words with spaces

I loved word arrays , but today I run into a problem:

> a = %w[ faq contact 'about us' legal 'bug reports' ] => ["faq", "contact", "'about", "us'", "legal", "'bug", "reports'"] > a = %w[ faq contact "about us" legal 'bug reports' ] => ["faq", "contact", "\"about", "us\"", "legal", "'bug", "reports'"] 

How can I highlight a white element ?

+7
source share
1 answer

You can avoid gaps

 a = %w[ faq contact about\ us legal bug\ reports ] a # => ["faq", "contact", "about us", "legal", "bug reports"] 

But I would still think about using "full" array literals. In this case, they are less confusing.

+12
source

All Articles