From: Keith Fahlgren Date: 2007-05-26T04:04:08+09:00 Subject: Re: Introducing the "it" keyword On 5/24/07, Greg Fodor wrote: > A common pattern seen in a lot of ruby code is: > > g(m(x)) if/unless/while/until h(m(x)) Hmm, this really isn't far from the Ruby equivalent of the common Scheme/Lisp anaphoric-if macro I've always wanted. Here's the On Lisp snippet about the same: http://www.bookshelf.jp/texi/onlisp/onlisp_17.html#SEC111 (I picked up the AIF habbit from a Graham colleague/protoge, so those folks may be the only ones who use it). Basically, I just want if to take a block. Here's that expressed as code: # pretend num_or_nil was very expensive def num_or_nil r = rand(2) if r == 1 1 else nil end end # => nil if num_or_nil {|it| it + 20 } # => 21 or nil HTH, Keith