Module: Enumerable
- Defined in:
- lib/everythingrb/core/enumerable.rb
Overview
Extensions to Ruby’s core Enumerable module
These additions make working with any enumerable collection more expressive by combining common operations into convenient methods.
Instance Method Summary collapse
-
#join_map(join_with = "", with_index: false) {|element, index| ... } ⇒ String
Combines filter_map and join operations.
Instance Method Details
#join_map(join_with = "", with_index: false) {|element, index| ... } ⇒ String
Combines filter_map and join operations
38 39 40 41 42 43 44 45 46 |
# File 'lib/everythingrb/core/enumerable.rb', line 38 def join_map(join_with = "", with_index: false, &block) block = ->(i) { i } if block.nil? if with_index filter_map.with_index(&block).join(join_with) else filter_map(&block).join(join_with) end end |