Skip to content

Latest commit

 

History

History
15 lines (10 loc) · 431 Bytes

nil_question.md

File metadata and controls

15 lines (10 loc) · 431 Bytes

nil?

The pseudo-method nil? determines whether an expression's runtime type is Nil. For example:

a = 1
a.nil?          # => false

b = nil
b.nil?          # => true

It is a pseudo-method because the compiler knows about it and it can affect type information, as explained in if var.nil?(...).

It has the same effect as writing is_a?(Nil) but it's shorter and easier to read and write.