Class: Object

Inherits:
BasicObject
Defined in:
lib/maybe.rb,
lib/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#try(*a, &b) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/maybe.rb', line 2

def try(*a, &b)
  if a.empty? && block_given?
    yield self
  else
    public_send(*a, &b) if respond_to?(a.first)
  end
end