In the second, deprecated, form, a generated Enumerator iterates over the given object using the given method with the given arguments passed.
Use of this form is discouraged. Use Kernel#enum_for or Kernel#to_enum instead.
e = Enumerator.new(ObjectSpace, :each_object)
#-> ObjectSpace.enum_for(:each_object)
But (({#enum_for})) and (({#to_enum})) are not available to subclasses of (({BasicObject})). In fact, I was defining (({#to_enum})) for a class that is a subclass of (({BasicObject})), and now I get warning of deprecation.
=end
((*In the second, deprecated, form, a generated Enumerator iterates over the given object using the given method with the given arguments passed.
Use of this form is discouraged. Use Kernel#enum_for or Kernel#to_enum instead.
e = Enumerator.new(ObjectSpace, :each_object)
#-> ObjectSpace.enum_for(:each_object)
But #enum_for and #to_enum are not available to subclasses of BasicObject. In fact, I was defining #to_enum for a class that is a subclass of BasicObject, and now I get warning of deprecation.
@nobu (Nobuyoshi Nakada) I found that out but it seems kind of hackish way to have to do it. (Also a little counter-intuitive since Kernel is not in BasicObject). I ended up with: