Sha256: 314fe21b95dbe72e82753722433f992423914a4b38177e154e2bfbbcdab57c90
Contents?: true
Size: 565 Bytes
Versions: 9
Compression:
Stored size: 565 Bytes
Contents
# frozen_string_literal: true require 'forwardable' require 'set' Array.class_eval do unless method_defined?(:compact_map) # @return [Array] # Similar to `filter_map` but excludes `nil` instead of falsy def compact_map return to_enum(:compact_map) unless block_given? r = [] each do |*args| result = yield(*args) r.push(result) unless result.nil? end r end end end Set.class_eval do unless method_defined?(:compact_map) extend Forwardable def_delegators :to_a, :compact_map end end
Version data entries
9 entries across 9 versions & 1 rubygems