From: Tammo Tjarks Date: 2008-05-25T05:54:22+09:00 Subject: Re: lambda, ->, haskell, and so on I am not sure if that fits to the thread. I have not used yet the more sophisticated features of ruby. I like it mostly because I sometimes get the impression that it can read my mind ;). I like especially the iterators and blocks. Therefore my question. With respect to the question how to provide several blocks to a method. Is it possible to implement something like that: a = Example.new a.cond_each [{|a| a%2==0}, { 'even'},{|c| "it is #{c}"}] Then the blocks could maybe adressed like that: class Example < Array def cond_each each {|arrel| if yield[0] arrel then yield[1] else yield[2] arrel end } end end would be something like that possible for the parser? Is that a already an existing idea or maybe even somewhere implemented? Tammo Am Freitag, 23. Mai 2008 schrieb Nikolai Weibull: > 2008/5/23 : > > # Use coupled {{ }} > > named_scope :recent, {{|time = 2.weeks.ago| {:conditions => > > ["released_at > ?", time]} }} > > What I don't quite understand is why we can't have multiple blocks to > a method. All but the last would be converted to anonymous functions > that become normal parameters and the last would be a block that can > be yielded to as before. I just read > http://pragdave.blogs.pragprog.com/pragdave/2008/05/new-lambda-synt.html > and I'd prefer > > a = 0 > my_while { a < 5 } do > puts a > a += 1 > end > > over > > a = 0 > my_while -> { a < 5 } do > puts a > a += 1 > end > > (And I'd prefer 5.times{ |a| puts a } over both alternatives.)