Ruby Percent Literals

Posted: October 26, 2010. Tags: Ruby

This list can be a pain to track down, but it turns out the Wikipedia page for Ruby Literals has a nice list:

Modifier Meaning
%q[ ] Non-interpolated String (except for \\ \[ and \])
%Q[ ] Interpolated String (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