On Mon, Dec 28, 2009 at 1:28 AM, Rob Biedenharn <[email protected]> wrote:
> As for predicate methods returning true or false, the Numeric#nonzero? > to which the OP compares nonblank? is a perfect counter example. The > way that it was explained to me (by Jim Weirich, iirc) was that a > predicate should return either false/true or nil/"not nil" (where "not > nil" is typically a useful object). This is precisely how > Numeric#nonzero? behaves. No, no. Predicates return true or false _values_. The implementor decides which one he wants to return, and it is not required/expected that it is is one of the singletons true/false. In that sense nonzero? is not a counter-example. But you are not going to do arithmetic with the value returned by nonzero? right? Predicates should only have a boolean contract, the chosen returned values shouldn't be documrented or relevant to client code. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
