I’ve been doing a lot of reading lately, most of that in regards to user authentication for the API I’m working on. I usually end up seeing new things that I mess around with to see how they work. One of those is the
try method provided by rails.
So, I thought this method was really cool. Unfortunately I don’t remember exactly where I came across it. It was my first time encountering it. Apidock has a pretty good example and explanation here. So basically, it returns
nil if the object doesn’t respond to the passed method, rather than
I suppose the only possible drawback would be readability. I could see something like:
Reading better than:
Just kind of bumped into this method, but thought it seemed like it could be pretty handy.