4 ms·
Will this correctly retrieve 0 values? AFAIK 0 is falsey in Ruby ``` return nil unless entry ```
by wood-porch 1y ago
Will this correctly retrieve 0 values? AFAIK 0 is falsey in Ruby
```
return nil unless entry
```
- chowells 1y agoNo, Ruby is more strict than that. Only nil and false are falsely.
- wood-porch 1y agoDoesn't that shift the problem to caching false then :D
- RangerScience 1y agoyou can probably always just do something like: def no_items? !items.present? end def items # something lone end memoize :items, ttl: 60, max_size: 10` just makes sure the expensive operation results in a truthy value, then add some sugar for the falsey value, done.