cells
cells copied to clipboard
Properly check for key presence
Hashes can have default values different from nil, see https://docs.ruby-lang.org/en/2.5.0/Hash.html#method-i-default-3D
So we must not rely on the hash returning nil for missing keys.
But if the value is nil, then Collection.new will crash since nil don't have #each_with_index
That is correct, but why would the user explicitly set the collection to nil? How does this differ from setting the collection to true or the number 3, which we don't protect against either?
The usual contract of a collection with no items is, well, an empty collection. :wink: