Suraj Kurapati wrote:
> Todd Benson wrote:
>> I would think that you would want to maintain the ? behavior across
>> the board.  In other words, it should return TrueClass or FalseClass
>> objects.
> 
> Why?  In Ruby, anything that is neither nil nor false is the same as 
> true...  I cannot express how many thousands of times this convention 
> has simplified my code and eased my life!  Furthermore, like method 
> aliases, this convention falls in line with Ruby's TIMTOWDI philosophy.
> 
> So, forcing question-mark methods to return only 'true' and 'false' 
> feels far too restrictive and seems to follow a 
> there's-only-one-way-to-do-it philosophy IMHO.

Forcing would be bad, but there is the convention that foo? returns true 
vs. false, not something vs. nil.

If a foo? method happens to be returning something other than TrueClass, 
and you start depending on that quirk, you run the risk that a later 
version of that method returns some other non-nil/non-false  object.

It's similar to the use of foo!.   You don't *have* to use the bang only 
when your method is doing something destructive, but you'd be foolish 
not to follow the  conventions.



-- 
James Britt

"Programs must be written for people to read, and only incidentally
  for machines to execute."
   - H. Abelson and G. Sussman
   (in "The Structure and Interpretation of Computer Programs)