String alternatives in Ruby

Posted by John Maddux Published on August 14, 2014

Instead of:
“A cat in a hat”
You can use:
%Q/A cat in a hat/
%/A cat in a hat/


or

“The number is #{2 + 3}” => “The number is 5”
%Q/The number is #{2 + 3}” => “The number is 5”


Instead of:
‘A frog in a bog’
You can use:
%q/A frog in a bog’

But not:

%q/The number is #{2 + 3}” => “The number is #{2 + 3}”