 7c72b0c68a
			
		
	
	
		7c72b0c68a
		
	
	
	
	
		
			
			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: Xu Cheng <xucheng@me.com>
		
			
				
	
	
		
			12 lines
		
	
	
		
			270 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			12 lines
		
	
	
		
			270 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| 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
 |