1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Update the guides.

This commit is contained in:
José Valim 2010-11-14 16:22:21 +01:00
parent 88688cdd8e
commit fae4264a7e

View file

@ -167,6 +167,12 @@ def log_info(sql, name, ms)
end
</ruby>
+try+ can also be called without arguments but a block, which will only be executed if the object is not nil:
<ruby>
@person.try { |p| "#{p.first_name} #{p.last_name}" }
</ruby>
NOTE: Defined in +active_support/core_ext/object/try.rb+.
h4. +singleton_class+