Awesome
Egocentric Nil
Creates a block, where nil
does not raise NoMethodError
s
egonil do
nil.some_methods.that[:do].not.exist
end
Further Information
- The Hopelessly Egocentric Blog Post
- The 25 Bytes of Ruby Joy!
- Safe navigation operator
- Null objects with null_question and exists or null_plus
Setup
Add to your Gemfile
:
gem 'egonil'
MIT License
Copyright (C) 2010-2016 Jan Lelis https://janlelis.com. Released under the MIT license.