Class: NilClass
Overview
Add #blank? method to NilClass class.
Instance Method Summary collapse
-
#blank? ⇒ TrueClass
Nil is always blank.
- #clone? ⇒ Boolean
-
#dup! ⇒ Object
Since NilClass is immutable it cannot be duplicated.
- #dup? ⇒ Boolean
-
#try(*args) ⇒ Object
Calling ‘try` on `nil` always returns `nil`.
- #try!(*args) ⇒ Object
Instance Method Details
#blank? ⇒ TrueClass
Nil is always blank
30 31 32 |
# File 'lib/garcon/core_ext/nil.rb', line 30 def blank? true end |
#dup! ⇒ Object
Since NilClass is immutable it cannot be duplicated. For this reason #try_dup returns self
.
nil.dup! #=> nil
50 |
# File 'lib/garcon/core_ext/nil.rb', line 50 def dup! ; self ; end |
#try(*args) ⇒ Object
Calling ‘try` on `nil` always returns `nil`. It becomes especially helpful when navigating through associations that may return `nil`.
37 38 39 |
# File 'lib/garcon/core_ext/nil.rb', line 37 def try(*args) nil end |
#try!(*args) ⇒ Object
41 42 43 |
# File 'lib/garcon/core_ext/nil.rb', line 41 def try!(*args) nil end |