3 ms·
Ruby's defined? keyword is an elegant way to check if a variable is defined or not and also to cache expensive operations. However, it's confusing, and a few go
by software_writer 3y ago
Ruby's defined? keyword is an elegant way to check if a variable is defined or not and also to cache expensive operations. However, it's confusing, and a few gotchas await the new Rubyist.
In this post, we'll learn how it works and how to use it correctly to cache expensive operations returning `nil` or `false`.