Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Where's Enumerable?

Reply
Thread Tools

Where's Enumerable?

 
 
Just Another Victim of the Ambient Morality
Guest
Posts: n/a
 
      08-14-2006
This fails with the follow error message:


require 'Enumerable'


c:/Program
Files/Ruby/lib/ruby/site_ruby/1.8/rubygems.custom_require.rb:18:in
'require__': No such file to load -- Enumberable (LoadError)
from c:/Program
Files/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in 'require'
from D:/temp/rubyfile.rb


So, what's up with that? I though Ruby came with Enumerable? What am I
doing wrong?
Thanks...



 
Reply With Quote
 
 
 
 
Hal Fulton
Guest
Posts: n/a
 
      08-14-2006
Just Another Victim of the Ambient Morality wrote:
> This fails with the follow error message:
>
>
> require 'Enumerable'
>
>
> c:/Program
> Files/Ruby/lib/ruby/site_ruby/1.8/rubygems.custom_require.rb:18:in
> 'require__': No such file to load -- Enumberable (LoadError)
> from c:/Program
> Files/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in 'require'
> from D:/temp/rubyfile.rb
>
>
> So, what's up with that? I though Ruby came with Enumerable? What am I
> doing wrong?
> Thanks...


You're looking too hard. It's not in a file, it's
a module that's part of the core.

class MyClass
include Enumerable
# ...
end


Cheers,
Hal


 
Reply With Quote
 
 
 
 
Rick DeNatale
Guest
Posts: n/a
 
      08-14-2006
On 8/13/06, Just Another Victim of the Ambient Morality
<(E-Mail Removed)> wrote:
> require 'Enumerable'

...
> 'require__': No such file to load -- Enumberable (LoadError)


Did you really say

require "Enumerable"

or

require "Enumberable"?


--
Rick DeNatale

http://talklikeaduck.denhaven2.com/

 
Reply With Quote
 
Just Another Victim of the Ambient Morality
Guest
Posts: n/a
 
      08-14-2006

"Hal Fulton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Just Another Victim of the Ambient Morality wrote:
>>
>> So, what's up with that? I though Ruby came with Enumerable? What
>> am I doing wrong?
>> Thanks...

>
> You're looking too hard. It's not in a file, it's
> a module that's part of the core.
>
> class MyClass
> include Enumerable
> # ...
> end


Ah, thank you. I would never have guessed that I _was_ looking too
hard...
...but now I have another question! I wanted to include Enumerable so I
could do something like this:


%w(a b c d).each_with_index do |obj, i|
if some_other_array[i] == obj
# do something
end
end


So, just to make sure I understood what I was doing, I removed the
"include Enumerable" line of my code and... it all still worked. Now,
what's up with that? Array has an "each_with_index" already? Does it
already include Enumerable?
Thank you for the clarification! I always like to understand what's
going on...



 
Reply With Quote
 
Logan Capaldo
Guest
Posts: n/a
 
      08-14-2006

On Aug 13, 2006, at 10:15 PM, Just Another Victim of the Ambient
Morality wrote:

>
> "Hal Fulton" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Just Another Victim of the Ambient Morality wrote:
>>>
>>> So, what's up with that? I though Ruby came with
>>> Enumerable? What
>>> am I doing wrong?
>>> Thanks...

>>
>> You're looking too hard. It's not in a file, it's
>> a module that's part of the core.
>>
>> class MyClass
>> include Enumerable
>> # ...
>> end

>
> Ah, thank you. I would never have guessed that I _was_ looking
> too
> hard...
> ...but now I have another question! I wanted to include
> Enumerable so I
> could do something like this:
>
>
> %w(a b c d).each_with_index do |obj, i|
> if some_other_array[i] == obj
> # do something
> end
> end
>
>
> So, just to make sure I understood what I was doing, I removed the
> "include Enumerable" line of my code and... it all still worked. Now,
> what's up with that? Array has an "each_with_index" already? Does it
> already include Enumerable?


Yes.

p Array.ancestors

> Thank you for the clarification! I always like to understand
> what's
> going on...
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments