Skip to content

Commit

Permalink
Merge pull request #34068 from schneems/schneems/micro-optimize-try-nil
Browse files Browse the repository at this point in the history
23% faster Nil#try
  • Loading branch information
schneems committed Oct 5, 2018
2 parents e1c6089 + 81d43f6 commit 0d4b2e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions activesupport/lib/active_support/core_ext/object/try.rb
Expand Up @@ -143,14 +143,14 @@ class NilClass
#
# With +try+
# @person.try(:children).try(:first).try(:name)
def try(*args)
def try(method_name = nil, *args)
nil
end

# Calling +try!+ on +nil+ always returns +nil+.
#
# nil.try!(:name) # => nil
def try!(*args)
def try!(method_name = nil, *args)
nil
end
end

0 comments on commit 0d4b2e4

Please sign in to comment.