Skip to content

Commit

Permalink
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kernel/common/enumerable.rb
Original file line number Diff line number Diff line change
@@ -87,13 +87,16 @@ def each_with_object(memo)

alias_method :with_object, :each_with_object

def flat_map(&block)
def flat_map
return to_enum(:flat_map) unless block_given?

inject([]) do |a, e|
result = block.call(e)
result = yield e

Rubinius::Type.object_respond_to_ary?(result) ? a.concat(result) : a.push(result)
end
end

alias_method :collect_concat, :flat_map

def lazy

0 comments on commit 86365bb

Please sign in to comment.