Existe-t-il une notation littérale pour un tableau de symboles?

J’aime cette expression littérale pour un tableau de chaînes:

%w( i can easily create arrays of words ) 

Je me demande s’il existe un littéral pour obtenir un tableau de symboles. Je sais que je peux faire

 %w( it is less elegant to create arrays of symbols ).map( &:to_sym ) 

mais ce serait tellement merveilleux de simplement utiliser un littéral.

Oui! C’est possible maintenant dans Ruby 2.0.0. Une façon d’écrire est la suivante:

 %i{foo bar} # => [:foo, :bar] 

Vous pouvez également utiliser d’autres délimiteurs, vous pouvez donc écrire %i(foo bar) ou %i!foo bar! par exemple.

Cette fonctionnalité a été initialement annoncée ici:

http://www.ruby-lang.org/zh_TW/news/2012/11/02/ruby-2-0-0-preview1-released/

Il est mentionné dans la documentation officielle de Ruby ici:

http://ruby-doc.org/core/doc/syntax/literals_rdoc.html#label-Percent+Ssortingngs

Dans Ruby 1.x, la liste des % limiteurs disponibles est malheureusement limitée

 Modifier Meaning %q[ ] Non-interpolated Ssortingng (except for \\ \[ and \]) %Q[ ] Interpolated Ssortingng (default) %r[ ] Interpolated Regexp (flags can appear after the closing delimiter) %s[ ] Non-interpolated Symbol %w[ ] Non-interpolated Array of words, separated by whitespace %W[ ] Interpolated Array of words, separated by whitespace %x[ ] Interpolated shell command