提交 7f8d2cdb 编写于 作者: X Xavier Noria

AS guide: documents Object#presence

上级 2e59151c
......@@ -48,6 +48,14 @@ The method +present?+ is equivalent to +!blank?+:
assert @response.body.present? # same as !@response.body.blank?
</ruby>
h4. +presence+
The +presence+ method returns its receiver if +present?+, and +nil+ otherwise. It is useful for idioms like this:
<ruby>
host = config[:host].presence || 'localhost'
</ruby>
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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册