Avoiding null for an easier life

One thought on “Avoiding null for an easier life”

  1. `nil` and `undefined` are different. In Ruby, you have a concept of `nil` but you also have a concept of un`defined?`

    `nil` has a place in languages that embrace it and just like any other tool you must use it properly.

    You can use the similar `optional` pattern in Ruby: `if coffee_metadata = coffees.first&.fetch(:metadata)`

    However, you are right that it’s not enforced like in other languages… but of course there are plenty of other ways to shoot yourself in the foot 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s