Space in the ruby array by %w
RubyArraysRuby Problem Overview
How can I add space character in the ruby array if I want to use %w(a b c) syntax?
Ruby Solutions
Solution 1 - Ruby
Escape it:
%w(a b\ c) # => ["a", "b c"]
Solution 2 - Ruby
Try this:
>> a = %w(a\ b c)
=> ["a ", "b", "c"]
Solution 3 - Ruby
Try this:
>> a = %W[a \s b]
=> ["a", " ", "b"]