Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Allow optional arguments and/or block for Object#try

#1425

As suggested by Pat Nakajima in the comments of: http://github.com/rails/rails/co...

No patch was submitted yet, but I needed this behaviour, so here it is.

Reported by Eloy Duran · November 21st, 2008 @ 08:53 AM

State: resolved
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Luciano G. Panaro
    Luciano G. Panaro

    Based on Eloy's patch I added the option of using a dynamic try_* method instead of calling try directly.

    So you would do @person.try_name (instead of @person.try(:name), even though you can still do that too).

    Any thoughts?

    November 21st, 2008 @ 02:36 PM

  2. Michael Siebert
    Michael Siebert

    +1 for for the original patch

    November 24th, 2008 @ 11:15 AM

  3. Levin Alexander
  4. Repository
    Repository
    • State changed from new to resolved

    (from [823b623fe2de8846c37aa13250010809ac940b57]) Allow optional arguments and/or block for Object#try like Object#send does. [#1425 Allow optional arguments and/or block for Object#try state:resolved]

    Original suggestion by Pat Nakajima.

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    November 24th, 2008 @ 05:54 PM

  5. Michael Siebert