Scott Watermasysk Husband, Father, Bootstrapper, Developer, Builder, Shipper.

Ruby Lonely Operator

Ruby 2.3 introduced a feature called the “Lonely Operator” (which I somehow missed until recently).

Instead of:

user && user.address && user.address.street

You can write it like this:

user&.address&.street