This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 823b623fe2de8846c37aa13250010809ac940b57
tree 7bf0e7e557bdedb57226cd35fef12f7e9fbbea4b
parent fffb1da3f22852c722dbc4436ec7c924435d29a5
tree 7bf0e7e557bdedb57226cd35fef12f7e9fbbea4b
parent fffb1da3f22852c722dbc4436ec7c924435d29a5
... |
... |
|
... |
... |
|












This definition of try would seriously benefit from being implemented like andand, at least from my side of the fence. Cheers! -=r
rogerdpack is right. The current semantic has many problems.
Firstly the major usecase for try is to catch the case when the receiver is nil, not so much if the method is defined on the receiver. There are also lots of methods on nil, so e.g. object.try(:id) will not archive anything besides subtle errors.
Secondly, because catching the first missing method is not enough, one often sees cascades of two ore more tries:
but (apart from the hard to read syntax) it can hide many problems, because if address is defined one expects to have a reset method on it and otherwise get an exception. So like in andand it would be better to have something like
User.admin.try { |u| u.address.reset }I guess this form can even be implemented without breaking compatibility with the old form (because the current implementation expects a “method” parameter)
Sorry it should’ve read
User.admins.first.try { |u| u.address.reset }