Skip to content
Permalink
Browse files

Merge pull request #599 from kostya/collect_concat

enumerable#collect_concat
  • Loading branch information
alex committed Apr 11, 2013
2 parents 3d372be + 11fa47d commit a431fb7ec4add7611177999205be47f3ece6bd53
@@ -330,4 +330,19 @@ def sort(&block)
def sort_by(&block)
to_a.sort_by!(&block)
end

def collect_concat(&block)
return self.enum_for(:collect_concat) unless block
out = []
self.each do |e|
v = yield(e)
if v.respond_to?(:to_ary) && ary = Array.try_convert(v)
out.concat(ary)
else
out << v
end
end
out
end
alias flat_map collect_concat
end

This file was deleted.

This file was deleted.

0 comments on commit a431fb7

Please sign in to comment.