Sha256: bce9aa84bdbc756f31fc447b9625aba7dfa315d87c63dea86f55caaaeb8cd2ab

Contents?: true

Size: 242 Bytes

Versions: 2

Compression:

Stored size: 242 Bytes

Contents

unless nil.respond_to?(:try)
  class Object
    def try(*a, &b)
      if a.empty? && block_given?
        yield self
      else
        __send__(*a, &b)
      end
    end
  end

  class NilClass
    def try(*args)
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geokit-1.10.0 lib/geokit/core_ext.rb
geokit-1.9.0 lib/geokit/core_ext.rb