Is it a nil value : nil « Language Basics « Ruby






Is it a nil value

x =2
if x != nil   # Expression "x != nil" returns true or false to the if
  puts x      # Print x if it is defined
end

 








Related examples in the same category

1.Compact an array: it removes the nils
2.Assign nil to array element
3.If x is non-nil
4.see if it is nil: