Class: NilClass

Inherits:
Object show all
Defined in:
lib/hoodie/core_ext/blank.rb,
lib/hoodie/core_ext/try.rb

Overview

Add #blank? method to NilClass class.

Instance Method Summary collapse

Instance Method Details

#blank?TrueClass

Nil is always blank

nil.blank?        #=>  true

Returns:



55
56
57
# File 'lib/hoodie/core_ext/blank.rb', line 55

def blank?
  true
end

#try(*args) ⇒ Object

Calling ‘try` on `nil` always returns `nil`. It becomes especially helpful when navigating through associations that may return `nil`.



61
62
63
# File 'lib/hoodie/core_ext/try.rb', line 61

def try(*args)
  nil
end

#try!(*args) ⇒ Object



65
66
67
# File 'lib/hoodie/core_ext/try.rb', line 65

def try!(*args)
  nil
end