Sha256: 46863bf3e1fd1ac2489344c2b59808004b8846a8d66470932019bf17fed0b7cb
Contents?: true
Size: 408 Bytes
Versions: 3
Compression:
Stored size: 408 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, *args) send(sym, *args) end alias_method :respond_with_value, :respond end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-2.2.0 | lib/core/facets/kernel/respond.rb |
facets-2.2.1 | lib/core/facets/kernel/respond.rb |
facets-2.3.0 | lib/core/facets/kernel/respond.rb |