From cd2d3664e3b434d15b6c19e652befb386187642f Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 24 Oct 2014 14:22:22 -0700 Subject: Revert a change made to the example in 1ac4525 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @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] --- activesupport/lib/active_support/core_ext/object/try.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') 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 -- cgit v1.2.3