Hi, At Mon, 17 May 2004 20:34:05 +0900, Kristof Bastiaensen wrote in [ruby-talk:100500]: > filter([[method = :each], *args, ] block) > yield values for which block returns true > > 3.filter(:times, &lambda{ |i| i[0] == 0 }) do |n| > puts "%i is even" % n > end > => 2 is even $ ruby -c 3.filter(:times, &lambda{ |i| i[0] == 0 }) do |n| puts "%i is even" % n end -:3: both block arg and actual block given > and now the fun stuff (turning into an enum): > > 5.enum_filter(:times){ |i| i[0] == 0 }.collect > => [2, 4] Is it a method of Enumerator, although Integer doesn't include it? > (2)* Enumerable::Enumerator takes a optional block > > powers = 4.enum_for(:times){ |i| i * i } > powers.collect > => [0, 1, 4, 9] Seems considerble, IMHO. -- Nobu Nakada