Good notes posted by mavvie
RSS feed![Default_avatar_30](https://www.gravatar.com/avatar/b8da33a5dbfb1a3567cd5d2d3ab783b4?size=30&default=http://apidock.com/images/default_avatar_30.png)
3 thanks
In Rails 4 it DOES return nil, even if the object you try from isn't nil
The try method does not raise a NoMethodError if you call a method that doesn’t exist on an object.
a = Article.new a.try(:author) #=> #<Author ...> nil.try(:doesnt_exist) #=> nil a.try(:doesnt_exist) #=> nil
Note:
a.try(&:doesnt_exist) #=> Raises NoMethodError