Sha256: 0bf549c017d695edb100dc6f996e2cc27a43bf789b34c655b59c4a44131c7574
Contents?: true
Size: 399 Bytes
Versions: 10
Compression:
Stored size: 399 Bytes
Contents
module Kernel # Like #respond_to? but returns the result of the call # if it does indeed respond. # # class X # def f; "f"; end # end # # x = X.new # x.respond(:f) #=> "f" # x.respond(:g) #=> nil # # CREDIT: Trans def respond(sym, *args) return nil if not respond_to?(sym) send(sym, *args) end alias_method :respond_with_value, :respond end
Version data entries
10 entries across 10 versions & 1 rubygems