Ruby has a safe operator, no need to try anymore
Wow, how did I miss this memo? Ruby 2.3 introduced a safe operator
Instead of
current_user.try(:profile).try(:bio)
you can now do
current_user&.profile&.bio
Wow, how did I miss this memo? Ruby 2.3 introduced a safe operator
Instead of
current_user.try(:profile).try(:bio)
you can now do
current_user&.profile&.bio
Looking for help? Obie Fernandez of Kickass Consulting has been one of the most sought-after Ruby experts worldwide for over 10 years. Ruby is one of our core languages at Kickass Consulting and we'd love to take a look at your project. Contact us today and find out how we can help you.