-2

I know there some object has nil? method, I want to know is there some method with nil?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
mlzboy
  • 14,343
  • 23
  • 76
  • 97

5 Answers5

0

No.

1.9.3p125 :002 > Object.methods.grep(/nil/)
 => [:nil?] 
Thilo
  • 17,565
  • 5
  • 68
  • 84
0
w.nil?

inverse of

!w.nil?
shingara
  • 46,608
  • 11
  • 99
  • 105
0

There is a similar answered post here: a-concise-explanation-of-nil-v-empty-v-blank-in-ruby-on-rails

Summarizing:

If you are using rails (not just ruby) there are three methods in your toolkit: .nil?, .empty? and .blank?

Follow the link to see the good description

Community
  • 1
  • 1
Jonathan
  • 16,077
  • 12
  • 67
  • 106
0

You could use present?, which acts as a sort of !blank?

William
  • 3,511
  • 27
  • 35
0

you could use defined? as well

apneadiving
  • 114,565
  • 26
  • 219
  • 213