Sha256: 05648503b7dd0864f8b416f0c87368b8df73f398a9f4b9f627fda26f5e140a09

Contents?: true

Size: 683 Bytes

Versions: 3

Compression:

Stored size: 683 Bytes

Contents

# DEPRECATE for 1.9.
unless (RUBY_VERSION[0,3] == '1.9')

  module Kernel

    # The tap K-Combinator. This yields self -and- returns self.
    #
    #   CREDIT: ?

    def tap(&b)
      if block_given?
        b.arity == 1 ? yield(self) : instance_eval(&b)
      end
      self
    end

    # This is just an odd consideration for #tap using Functor:
    #
    #   require 'facets/functor'
    #
    #   # Yield self -and- return self.
    #
    #   def tap(&b)
    #     if block_given?
    #       b.arity == 1 ? yield(self) : instance_eval(&b)
    #       self
    #     else
    #       Functor.new{ |op, *args| self.send(op, *args); self }
    #     end
    #   end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 lib/core/facets/kernel/tap.rb
facets-2.3.0 lib/core/facets/kernel/tap.rb
facets-2.2.1 lib/core/facets/kernel/tap.rb