Benx Shen's personal annotations on this page
Benxshen bookmarked
on 2009-10-24
-
in Ruby, there's a better way. You can use the
%qoperator to apply single-quoting rules, but choose your own delimiter to mark the beginning and end of the string literal.puts %q!c:\napolean's documents\tomorrow's bus schedule.txt!
puts %q/c:\napolean's documents\tomorrow's bus schedule.txt/
puts %q^c:\napolean's documents\tomorrow's bus schedule.txt^
puts %q(c:\napolean's documents\tomorrow's bus schedule.txt)
puts %q{c:\napolean's documents\tomorrow's bus schedule.txt}
puts %q<c:\napolean's documents\tomorrow's bus schedule.txt> -
puts %Q!Say "Hello," #{name}.!
puts %Q/What is "4 plus 5"? Answer: #{4+5}/
This link has been bookmarked by 1 people . It was first bookmarked on 24 Oct 2009, by Benx Shen.
-
-
in Ruby, there's a better way. You can use the
%qoperator to apply single-quoting rules, but choose your own delimiter to mark the beginning and end of the string literal.puts %q!c:\napolean's documents\tomorrow's bus schedule.txt!
puts %q/c:\napolean's documents\tomorrow's bus schedule.txt/
puts %q^c:\napolean's documents\tomorrow's bus schedule.txt^
puts %q(c:\napolean's documents\tomorrow's bus schedule.txt)
puts %q{c:\napolean's documents\tomorrow's bus schedule.txt}
puts %q<c:\napolean's documents\tomorrow's bus schedule.txt> -
puts %Q!Say "Hello," #{name}.!
puts %Q/What is "4 plus 5"? Answer: #{4+5}/
-
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.