String Things in Ruby
String alternatives in ruby
%Q
Alternative for double-quoted strings. Below are equivalent
1 2 3 |
|
You could replace (
and )
with non-alphanumeric characters.
1 2 3 4 |
|
%q
Alternative for single-quoted strings. But it can’t do expression substitution
1
|
|
%W
Used for double-quoted array.
1 2 |
|
%w
Used for single-quoted array. No expression substitution
1
|
|
%s
Used for symbols. No expression substitution.
1 2 |
|