try(*a, &b)
Instance Public methods
Invokes the public method whose name goes as first argument just like
public_send does, except that if the receiver does not respond
to it the call returns nil rather than raising an exception.
This method is defined to be able to write
@person.try(:name)
instead of
@person ? @person.name : nil
try returns nil when called on nil
regardless of whether it responds to the method:
nil.try(:to_i) # => nil, rather than 0
Arguments and blocks