tags:

views:

78

answers:

2

How can i add space character in the ruby array if i want to use %w(a b c) syntax?

+7  A: 

Escape it:

%w(a b\ c) # => ["a", "b c"]
Gareth
Thanks. After your answer i understand how i can do it. I wanted just this - %w(a \ b c) # => ["a", " ", "b", "c"]
nash
+1  A: 

Try this:

>> a = %w(a\  b c)
=> ["a ", "b", "c"]
Sudhanshu