什么是最佳做法?使用try或使用rescue?
user.try(:email)
Run Code Online (Sandbox Code Playgroud)
VS
user.email rescue nil
Run Code Online (Sandbox Code Playgroud)
post.try(:comments).try(:first).try(:author)
Run Code Online (Sandbox Code Playgroud)
VS
post.comments.first.author rescue nil
Run Code Online (Sandbox Code Playgroud)
使用其中任何一个有什么不同吗?