Skip to content
Snippets Groups Projects
Commit 7c72b0c6 authored by Xu Cheng's avatar Xu Cheng
Browse files

backport flat_map for Ruby 1.8

Code is copied from
https://github.com/marcandre/backports/blob/master/lib/backports/1.9.2/enumerable/flat_map.rb


(MIT License by Marc-Andre Lafortune)

Closes Homebrew/homebrew#42543.

Signed-off-by: default avatarXu Cheng <xucheng@me.com>
parent ae0e2707
No related branches found
No related tags found
Loading
module Enumerable
def flat_map
return to_enum(:flat_map) unless block_given?
r = []
each do |*args|
result = yield(*args)
result.respond_to?(:to_ary) ? r.concat(result) : r.push(result)
end
r
end unless method_defined?(:flat_map)
end
......@@ -3,6 +3,7 @@ require "extend/fileutils"
require "extend/pathname"
require "extend/ARGV"
require "extend/string"
require "extend/enumerable"
require "os"
require "utils"
require "exceptions"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment