class Object

Public Instance Methods

try(*a, &b) click to toggle source
# File lib/core_ext/object/try.rb, line 14
def try(*a, &b)
  try!(*a, &b) if a.empty? || respond_to?(a.first)
end
try!(*a) { |self| ... } click to toggle source
# File lib/core_ext/object/try.rb, line 2
def try!(*a, &b)
  if a.empty? && block_given?
    if b.arity.zero?
      instance_eval(&b)
    else
      yield self
    end
  else
    public_send(*a, &b)
  end
end