Pattern: Unsafe method navigation chain
Issue: -
The safe navigation operator returns nil if the receiver is
nil. If you chain an ordinary method call after a safe
navigation operator, it raises NoMethodError
.
# bad
x&.foo.bar
x&.foo + bar
x&.foo[bar]
# good
x&.foo&.bar
x&.foo || bar
Attribute | Value |
---|---|
Whitelist | present?, blank?, presence, try |