You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful if NArray provided a standard ruby Enumerator interface. All that would be required is for my_narray.each to return an Enumerator object, like my_array.each does when called without a block.
This would enable use cases such as my_narray.each.each_with_index { ... } or my_narray.each.map { ... } etc.
The follow monkey patch provides this functionality but I'm sure a better solution is possible.
class NArray
alias_method :native_each, :each
def each
return enum_for :each unless block_given?
native_each { |item| yield item }
end
end
The text was updated successfully, but these errors were encountered:
It would be useful if NArray provided a standard ruby Enumerator interface. All that would be required is for
my_narray.each
to return an Enumerator object, likemy_array.each
does when called without a block.This would enable use cases such as
my_narray.each.each_with_index { ... }
ormy_narray.each.map { ... }
etc.The follow monkey patch provides this functionality but I'm sure a better solution is possible.
The text was updated successfully, but these errors were encountered: