What is the difference between nil and false in Ruby?

Technology CommunityCategory: RubyWhat is the difference between nil and false in Ruby?
VietMX Staff asked 3 years ago

nil:

  • nil cannot be a value
  • nil is returned where there is no predicate
  • nil is not a boolean data type
  • nil is an object of nilclass

false:

  • false can be a value
  • in case of a predicate, true or false is returned by a method
  • false is a boolean data type
  • false is an object of falseclass