Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Created September 23, 2009 09:17
Show Gist options
  • Save thenoseman/191858 to your computer and use it in GitHub Desktop.
Save thenoseman/191858 to your computer and use it in GitHub Desktop.
if RUBY_VERSION < "1.8.7"
require 'enumerator'
module Enumerable
alias_method :original_each_slice, :each_slice
def each_slice(count, &block)
if block_given?
# call original method when used with block
original_each_slice(count, &block)
else
# no block -> emulate
self.enum_for(:original_each_slice, count)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment