class NilClass

def try(*)

Experimental RBS support (using type sampling data from the type_fusion project).

def try: (*unused *) -> untyped

This signature was generated using 1 sample from 1 application.

@person.try(:children).try(:first).try(:name)
With +try+

@person && @person.children.any? && @person.children.first.name
Without +try+

nil.try(:name) # => nil

It becomes especially helpful when navigating through associations that may return +nil+.
Calling +try+ on +nil+ always returns +nil+.
def try(*)
  nil
end