you can escape spaces when using ruby’s %w operator

Discovered something cool about ruby’s %w operator the other day. You can escape spaces in it.

%w{there will be four\ elements}

evaluates to:

['there', 'will', 'be', 'four elements']

Just a little neat tidbit I haven’t seen in any examples.

About Evan Gates

Switching from Visual Studio and C# to vim and ruby.
This entry was posted in ruby and tagged , , , , . Bookmark the permalink.

Leave a Reply