Reputation: 18250
I came to love word arrays, but today I face a challenge:
> 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 have whitespace an element?
Upvotes: 8
Views: 2243
Reputation: 230346
You can escape space characters
a = %w[ faq contact about\ us legal bug\ reports ]
a # => ["faq", "contact", "about us", "legal", "bug reports"]
But I'd still consider using "full" array literals. They are less confusing in this case.
Upvotes: 16