ruby %w equivalent

MonkeeSage MonkeeSage at gmail.com
Mon Sep 25 15:59:48 EDT 2006


hg wrote:
> Why would they want to make such an obscure API ? ... didn't they have
> Python to learn from (I am truly amazed - nothing cynical ...just ...
> why ?!!!!)

In ruby there are several special literal notations, just like python.
In ruby it goes like this:

%{blah} / %Q{blah} # same as "blah" but igornes " and '
%q{blah} # same as 'blah' but no interpolation
%w{blah blah} # same as "blah blah".split
%r{blah} # same as /blah/
%x{ls} # same as `ls`

Sometimes they are very useful, and sometimes they are cumbersome. It's
up to the programmer to implement them effectively.

Regards,
Jordan




More information about the Python-list mailing list