[#18121] [Ruby 1.8.7 - Bug #405] (Open) ssl.rb:31: [BUG] Bus Error — Anonymous <redmine@...>

Issue #405 has been reported by Anonymous.

14 messages 2008/08/04

[#18130] Re: New array methods cycle, choice, shuffle (plus bug in cycle) — Brian Candler <B.Candler@...>

> Seriously though... Array.first is a noun.

10 messages 2008/08/05

[#18319] NEW Command: absolute_path() -- — "C.E. Thornton" <admin@...>

Core,

14 messages 2008/08/16
[#18321] Re: NEW Command: absolute_path() -- — Yukihiro Matsumoto <matz@...> 2008/08/18

Hi,

[#18381] [Bug #496] DRb.start_service(nil) is very slow — Hongli Lai <redmine@...>

Bug #496: DRb.start_service(nil) is very slow

11 messages 2008/08/25

[ruby-core:18144] Re: Enumerators that know about a block

From: "David A. Black" <dblack@...>
Date: 2008-08-06 11:04:22 UTC
List: ruby-core #18144
Hi --

On Wed, 6 Aug 2008, Shugo Maeda wrote:

> Hi,
>
> 2008/8/6 David A. Black <dblack@rubypal.com>:
>>> You may need the lazy version of Enumerable#map that returns
>>> Enumerator instead of Array.
>>>
>>>  e = [1, 2, 3].lazy_map {|x| x * 10}
>>>  p e.next #=> 10
>>>  p e.next #=> 20
>>
>> Is that an actual method (I couldn't find it anywhere) or just a
>> hypothetical example? I'm still wondering why enumerators aren't
>> designed to do that automatically if they're given a block upon
>> initialization.
>
> It's just a hypothetical example.  Enumerator can't do that automatically,
> because Enumerable#map is implemented to produce Array.
>
> If you don't mind memory consumption, you can write like this:
>
>  e = [1, 2, 3].map {|x| x * 10}.each
>  p e.next #=> 10
>  p e.next #=> 20

I'd rather have an enumerator that already knows both the method it
represents and the block it's supposed to use. I guess I got used to
it when we had:

   e = array.enum_for(:map, &block)

and I never understood why that was removed. I think it's someone
else's "least surprise" :-)


David

-- 
Rails training from David A. Black and Ruby Power and Light:
  *  Advancing With Rails    August 18-21    Edison, NJ
  * Co-taught by D.A. Black and Erik Kastner
See http://www.rubypal.com for details and updates!

In This Thread