Posted over 4 years ago. Visible to the public. Linked content.

Defining Ruby strings with % (percent) notation

The attached post 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>"

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Henning Koch
Last edit:
over 4 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more