Re: Why, oh, why, little regexp?



On 10/31/07, Brian Adkins <lojicdotcom@xxxxxxxxx> wrote:
On Oct 30, 11:58 pm, Phrogz <phr...@xxxxxxx> wrote:
On Oct 30, 9:30 pm, Daniel Waite <rabbitb...@xxxxxxxxx> wrote:

That's clever use of ?a, which I recognize but have never seen anyone
use before. Thanks for the example!

My current favorite use for the ?x syntax is converting single-
character strings representing digits into their integer form:

Yeah, so you can squeeze Ruby code into small places :)

1.upto(?d){|i|i%3<1&&x=:Fizz;puts i%5<1?"#{x}Buzz":x||i}

Except under the upcoming revision (1.9) of the (Ruby) Rules of Golf,
the R(uby)&A(ncient) has outlawed that usage, and instituted the
penalty that ?d will no longer be 100, but "d".

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

.



Relevant Pages

  • Re: Why, oh, why, little regexp?
    ... character strings representing digits into their integer form: ... Yeah, so you can squeeze Ruby code into small places:) ...
    (comp.lang.ruby)
  • Re: Named arguments gem
    ... spot from different angles. ... LOL. ... Yeah, both solutions look similar. ... I havent tried to make it work with blocks or with ruby 1.9, ...
    (comp.lang.ruby)
  • Re: A crosspost from the Perl Community
    ... and there are no Ruby Monks. ... to answer questions I had in irc, but Perl monks it is not. ... Yeah Ruby just doesn't seem to have tons and tons of community. ...
    (comp.lang.ruby)
  • Re: Ruby doesnt implement x++ for Fixnums because ???
    ... in Ruby. ... Yeah. ... http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures ... http://en.wikipedia.org/wiki/Fair_Game_ (Scientology) <-- get educated! ...
    (comp.lang.ruby)
  • Re: Completely new programmer lacks direction
    ... Yeah I bought that for my girlfriend. ... Then she got a bit stuck on the ... Its been a long time since Ruby was ...
    (comp.lang.ruby)