Reputation: 558
The following methods are listed on the documentation page for the Enumerator
class:
::new
#each
#each_with_index
#each_with_object
#feed
#inspect
#next
#next_values
#peek
#peek_values
#rewind
#size
#with_index
#with_object
However when I do the following in irb
I receive false
:
>> Enumerator.methods.include?(:next)
false
Is this because even though the method can be used on instances of this class, the method isn't explicitly defined on the class itself, i.e. it is inherited? Having thought this I also checked Enumerator
superclasses and found that they do not contain this method either:
>> Enumerator.superclass.methods.include?(:next)
false
>> Enumerator.superclass.superclass.methods.include?(:next)
false
I'm sure I'm overlooking something quite fundamental..
Upvotes: 2
Views: 51
Reputation: 84
#next
is an instance method of the Enumerator class. Using Enumerator.instance_methods.include?(:next)
will return true
Upvotes: 5