Hi --

On Sun, 25 May 2008, Phlip wrote:

> Tammo Tjarks wrote:
>
>> a.cond_each [{|a| a%2==0}, { 'even'},{|c| "it is #{c}"}]
>
>> would be something like that possible for the parser? Is that a already an 
>> existing idea or maybe even somewhere implemented?
>
> I suspect I just did that to enable multiple arguments for assert_yin_yang.
>
> First, get 'lambda' out of the way:

Was it in the way? :-)

>  def _(&block); lambda(&block);  end
>
> Then, pass an arbitrary number of blocks and non-blocks in:
>
>    q = 41
>    assert_yin_yang _{ q +=  0 }, 'it broke!',
>                    _{ q == 42 }
>
> Inside the method, partition them into callables & diagnostic strings:
>
>  def assert_yin_yang(*args)
>    procks, diagnostic = args.partition{|p| p.respond_to? :call }
>
> Then, iterate an array of procks, calling each one!
>
> Is the new lambdoid operator going to replace my (dangerous) _ hack?

I'm not sure which part you consider dangerous, but basically with the
arrow thing you can do:

     assert_yin_yang -> { q +=  0 }, 'it broke!', -> { q == 42 }


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS         June 9-12            Berlin
   ADVANCING WITH RAILS   June 16-19           Berlin
   INTRO TO RAILS         June 23-26           London (Skills Matter)
See http://www.rubypal.com for details and updates!