A quick reference to format literals.
%q[ ] | Non-interpolated String (except for \\ \[ and \]) |
%Q[ ] | Interpolated String (default) |
%r[ ] | Interpolated Regexp (flags can appear after the closing delimiter) |
%i[ ] | Non-interpolated Array of symbols, separated by whitespace (after Ruby 2.0) |
%I[ ] | Interpolated Array of symbols, separated by whitespace (after Ruby 2.0) |
%w[ ] | Non-interpolated Array of words, separated by whitespace |
%W[ ] | Interpolated Array of words, separated by whitespace |
%x[ ] | Interpolated shell command |
%s[ ] | Non-interpolated symbol |
Note that you can use other characters in place of the [] if you are so inclined. Ex:
%w(foo bar)
returns [“foo”, “bar”]
Recent Comments