GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Ruby
Go To First  |  Previous Question  |  Next Question 
 Ruby  |  Question 17 of 22    Print  
How does nil and false duffer?

  
Total Answers and Comments: 3 Last Update: May 19, 2009     Asked by: nancyphilips 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 18, 2007 01:07:28   #1  
natchiar        

RE: How does nil and false duffer?
The difference of the methods nil and false is shown by executing nil.methods - false.methods and false.methods - nil.methods.

In a Hash nil cannot be a value but false can.

It is recommened that a method returns true or false if it is a predicate and a value or nil otherwise.

A method with suffix ? is usually a predicate but some built-in functions are not.

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 2Overall Rating: -2    
August 18, 2007 05:02:49   #2  
Manikandan Mca        

RE: How does nil and false duffer?
False is a boolean datatype
Nil is not a data type

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 2Overall Rating: -2    
May 19, 2009 03:13:35   #3  
kalyan.allampalli Member Since: May 2009   Contribution: 2    

RE: How does nil and false duffer?
In Ruby nil is an Object for NilClass

You can directly check as nil.class it will return NilClass.

Where as false is an object for FalseClass.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape