Browse files

AS guide: documents Object#presence

  • Loading branch information...
1 parent 2e59151 commit 7f8d2cdb1715ddfaa27eed892df7ca9884e5315a @fxn fxn committed Dec 30, 2009
Showing with 8 additions and 0 deletions.
  1. +8 −0 railties/guides/source/active_support_core_extensions.textile
@@ -48,6 +48,14 @@ The method +present?+ is equivalent to +!blank?+:
assert @response.body.present? # same as !@response.body.blank?
+h4. +presence+
+The +presence+ method returns its receiver if +present?+, and +nil+ otherwise. It is useful for idioms like this:
+host = config[:host].presence || 'localhost'
h4. +duplicable?+
A few fundamental objects in Ruby are singletons. For example, in the whole live of a program the integer 1 refers always to the same instance:

0 comments on commit 7f8d2cd

Please sign in to comment.