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:
parent
88688cdd8e
commit
fae4264a7e
1 changed files with 6 additions and 0 deletions
|
@ -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+
|
||||
|
|
Loading…
Reference in a new issue