diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-10-24 14:22:22 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-10-24 14:22:22 -0700 |
commit | cd2d3664e3b434d15b6c19e652befb386187642f (patch) | |
tree | 33c03f2475fe9ba2dc459a4a17fef0b88a026fb6 | |
parent | ea3cd40554a674989275e8b24f382e3c6409ce5a (diff) | |
download | rails-cd2d3664e3b434d15b6c19e652befb386187642f.tar.gz rails-cd2d3664e3b434d15b6c19e652befb386187642f.tar.bz2 rails-cd2d3664e3b434d15b6c19e652befb386187642f.zip |
Revert a change made to the example in 1ac4525
@carlosantoniodasilva pointed out that when `@person` is nil then this would blow up when you ended up calling `#first`on `nil`.
> "there’s no way to break a try chain when you enter it :D"
[ci skip]
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/try.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb index 5b5729eb92..56da398978 100644 --- a/activesupport/lib/active_support/core_ext/object/try.rb +++ b/activesupport/lib/active_support/core_ext/object/try.rb @@ -89,7 +89,7 @@ class NilClass # @person && @person.children.any? && @person.children.first.name # # With +try+ - # @person.try(:children).first.try(:name) + # @person.try(:children).try(:first).try(:name) def try(*args) nil end |