Where's Enumerable?

  • Thread starter Just Another Victim of the Ambient Morality
  • Start date
J

Just Another Victim of the Ambient Morality

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...
 
H

Hal Fulton

Just said:
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
 
R

Rick DeNatale

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

Did you really say

require "Enumerable"

or

require "Enumberable"?
 
J

Just Another Victim of the Ambient Morality

Hal Fulton said:
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 == 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...
 
L

Logan Capaldo

Hal Fulton said:
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 == 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top