From: Robert Klemme Date: 2008-04-30T16:57:17+09:00 Subject: Re: Sprintf: what does mean the percent symbol? 2008/4/29 David A. Black : > On Tue, 29 Apr 2008, Robert Klemme wrote: > > > I've searched on the ruby pickaxe and several other ruby books but I > > > haven't found anything on the % alone, obviously there are many use of > > > that combined with option (array: %w, string: %q,%Q, regexp: %r, ...). > > > > > > > That's a completely different story, here % I would not call "operator" > because it is not runtime effective. This occurrence of the percent sign is > evaluated at compile time, more precisely during parsing. All these are > convenience syntaxes to more easily express certain literals. For example, > if you have a regular expression containing forward slashes the %r form is > much easier on the eye: > > > > %r{/+} vs. /\/+/ > > > > But not the brain :-) I know there's no consensus about these things, Yeah, my initial reaction was "maybe not for _your_ brain". :-) > but I'll just put in a word for //. Having trained my brain to > understand /\/+/ at a glance, I always find it much harder to > understand things like {/+}, and similarly with /x-style regexes, > which I always have to slow down to read. I for my part find longish regular expressions much, much more readable and understandable if they are pulled apart with /x probably across multiple lines and with comments. > Chacun à son cerveau :-) I'm glad babelfish can help my brain decipher this. :-))) Kind regards robert -- use.inject do |as, often| as.you_can - without end