"Ernie Miller" <[email protected]> wrote in message news:[email protected]...

I agree that I don't much like the way it just dangles there like
that, but I don't see any other way to accomplish what's desired. In
working with it, I find that it helps to imagine yourself back in the
90s for a moment.

"User name equals Bill or user name equals Ted... NOT!"

OK, maybe I'm just odd. Or maybe the method name needs an exclamation
point. :) In all seriousness, though, it's not much different than
something like String#reverse.


Actually, I take that back. I updated the patch (still at
http://gist.github.com/360075) and added experimental support for an
alternate not syntax under Ruby 1.9, thanks to BasicObject#!.

articles = Article.scoped
articles.where(!articles.table[:title].eq('Hello!')).to_sql
=> "SELECT     \"articles\".* FROM       \"articles\" WHERE     (NOT
(\"articles\".\"title\" = 'Hello!'))"
articles.where(not(articles.table[:title].eq('Hello!'))).to_sql
=> "SELECT     \"articles\".* FROM       \"articles\" WHERE     (NOT
(\"articles\".\"title\" = 'Hello!'))"


I'm not fundemantally opposed to overriding the ! operator, as long as the result is strictly a locigal negation of the original, although some people may have a problem with it breaking the double negation to coerce to true boolean. Since that is a hack anyway, I don't much care for the loss.

I would however suggest that any documentation prefer the format used in the second example, as a way of encouraging readability. When the first case is used, an extra set of partentheses may help readability since somebody not particular familar with ruby's operator precedence could potentially misread it.

--
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.

Reply via email to