Sha256: 303188205da148b6e934069c9eb1365a9be14ac0cf492b15909af1389a17ef8d
Contents?: true
Size: 449 Bytes
Versions: 22
Compression:
Stored size: 449 Bytes
Contents
# frozen_string_literal: true require 'forwardable' require 'set' Array.class_eval do # @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 Set.class_eval do extend Forwardable def_delegators :to_a, :compact_map end
Version data entries
22 entries across 22 versions & 2 rubygems