DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Using The % Notation

05.03.2010
| 1824 views |
  • submit to reddit
        <snip>... a (wacky) perl-inspired way to quote strings: by using % (percent character) and specifying a delimiting character, for example:</snip>
%(test) #=> "test"
%(#{Time.now}) #=> "2010-05-03 14:11:18 +0100"
Resources:
 - <a href="http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals">Ruby Programming/Syntax/Literals - Wikibooks, collection of open-content textbooks</a> [wikibooks.org]