I have this method call I have to use…
financial_document.assets.length
But financial_document.assets could be nil.
I could use…
financial_document.assets.nil? ? '0' : financial_document.assets.length
Is there a less repetitive way to do that?
Personally, I would use the
oroperator/keyword:Either way,
.lengthis called on an array, giving you0ifnil.