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.
The webapp is full of
company.andand.namebut it seems we tend to favourcompany.try(:name)lately.However, abusing and chaining
.tryis a code smell: something is wrong way up