[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: does Object#to_enum exist?

Yukihiro Matsumoto

4/26/2007 8:09:00 AM

Hi,

In message "Re: does Object#to_enum exist?"
on Thu, 26 Apr 2007 16:45:36 +0900, Dan Zwell <dzwell@gmail.com> writes:

|I saw someone post a snippet of code that turned an object (with some
|sort of "each" method) into an enumerable. It looked really neat, until
|I tried:
|
| >> "abcdef".to_enum(:each_byte)
|NoMethodError: undefined method `to_enum' for "abcdef":String
| from (irb):1
| >>
|
|I looked it up and ri seems to think I have Object#to_enum.

It's available only for 1.9. You can use it with Enumerator
additional library installed.

matz.

2 Answers

Dan Zwell

4/26/2007 8:24:00 AM

0

Thank you. I feel silly for making such a newbie-ish mistake, but then
again, I'm a newbie.

Dan

Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: does Object#to_enum exist?"
> on Thu, 26 Apr 2007 16:45:36 +0900, Dan Zwell <dzwell@gmail.com> writes:
>
> |I saw someone post a snippet of code that turned an object (with some
> |sort of "each" method) into an enumerable. It looked really neat, until
> |I tried:
> |
> | >> "abcdef".to_enum(:each_byte)
> |NoMethodError: undefined method `to_enum' for "abcdef":String
> | from (irb):1
> | >>
> |
> |I looked it up and ri seems to think I have Object#to_enum.
>
> It's available only for 1.9. You can use it with Enumerator
> additional library installed.
>
> matz.
>
>

Robert Dober

4/26/2007 8:42:00 AM

0

On 4/26/07, Dan Zwell <dzwell@gmail.com> wrote:
> Thank you. I feel silly for making such a newbie-ish mistake, but then
> again, I'm a newbie.
It is from our mistakes that we learn, I was about to check for
#to_enum very recently but was too lazy and/or proud to ask, so I
learned too :)

Cheers
Robert
--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw