Read more

Defining Ruby strings with % (percent) notation

Henning Koch
July 11, 2014Software engineer at makandra GmbH

The attached post Show archive.org snapshot shows some alternative ways to define Strings in Ruby using the percent notation. This can be useful when you'd like to use quotes (") or single-quotes (') in your strings:

%(any alpha-numeric)
%[char can be]
%%used as%
%!delimiter\!! # escape '!' literal
%( (pa(re(nt)he)sis) ) #=> "(pa(re(nt)he)sis)"
%[ [square bracket] ]  #=> "[square bracket]"
%{ {curly bracket} }   #=> "{curly bracket}"
%< <pointy bracket> >  #=> "<pointy bracket>"
%< \<this works as well\> >  #=> "<this works as well>"
Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
Read more Show archive.org snapshot
Posted by Henning Koch to makandra dev (2014-07-11 17:43)