Which is the preferred way to determine if a chained call is nil? i.e:
company.andand.namecompany.try(:name)return nil if company.nil?; company.name(company or return nil).name
For the last one, you must use the predicate or rather than || to make the return work correctly.
Again, to emphasise:
tryhas very different semantics, and is not what you want here.(
trytestsrespond_to?, not if the recipient of the message isnil, which is possibly whyandandexists in the first place).