Skip to content
Browse files

Fixed docs for NilClass#try

  • Loading branch information...
1 parent 9556e9c commit af41d5540b0bab8c8cee8cbc7cbfb8fab0676518 @smartinez87 smartinez87 committed
Showing with 8 additions and 8 deletions.
  1. +8 −8 activesupport/lib/active_support/core_ext/object/try.rb
View
16 activesupport/lib/active_support/core_ext/object/try.rb
@@ -9,12 +9,12 @@ class Object
#
# ==== Examples
#
- # Without try
+ # Without +try+
# @person && @person.name
# or
# @person ? @person.name : nil
#
- # With try
+ # With +try+
# @person.try(:name)
#
# +try+ also accepts arguments and/or a block, for the method it is trying
@@ -35,17 +35,17 @@ def try(*a, &b)
end
class NilClass
- # Instances of NilClass return always +nil+
- # It becomes specially helpful when navigating through associations that may return nil
+ # Instances of +NilClass+ return always +nil+.
+ # It becomes specially helpful when navigating through associations that may return +nil+.
#
# === Examples
#
- # nil.try(:name) # => nil
+ # nill.try(:name) # => nil
#
- # Without try
- # @person && @person.children.first && @person.children.first.name
+ # Without +try+
+ # @person && !@person.children.blank? && @person.children.first.name
#
- # With try
+ # With +try+
# @person.try(:children).try(:first).try(:name)
def try(*args)
nil

0 comments on commit af41d55

Please sign in to comment.
Something went wrong with that request. Please try again.