Maybe it is just me, but I don't use features that I don't like in rails, just like I avoid calling private methods. In that sense, there's nothing that is preventing anyone from using `post.body.present?` instead of `post.body?`. My argument would be to let rational programmers decide what is best for their specific case. If you're on a team, set a style guide that picks a winner.
Allen Madsen http://www.allenmadsen.com On Thu, May 31, 2012 at 11:05 AM, Maksym Melnychok <[email protected]>wrote: > On Thursday, May 31, 2012 4:50:05 PM UTC+2, Steve Klabnik wrote: >> >> It's not saving a character. It's that !! is programmer talk, and ? is >> human talk. Ruby prefers human talk. >> > > well your kung-fu beats my kung-fu here > > i just don't think post.url? is talking proper human talk to me, i would > expect answer to that question to be "no, post is not a url" instead i > will get "yes, url attribute is not empty". > > > I guess Rafael meant another thing. You have boolean fields in > > PostgreSQL but someone might prefer to use some old ANSI types, like > > INTEGER for storing such booleans for some reason. > > i think that first of all this is rather an edge-case that shouldn't force > us to go against least surprise principle > > second - this directly goes against Steve's assumption that > > post = Post.new > post.id = 0 > assert post.id? > > should not fail (it fails because 0 is apparently false.. since when?) > > i personally think this smells a lot like PHP and it's non-logical, > generally ugly and wrong truthiness/falseness checks > > On Thursday, May 31, 2012 4:50:05 PM UTC+2, Steve Klabnik wrote: >> >> > but if we decide that there doesn't have to be semantical contribution >> to >> > your code from using attribute query methods then #{attribute}? is just >> > a shortcut for !!#{attribute} - so why do we need it in the first >> place? >> > saving 1 character is weird goal here. >> >> It's not saving a character. It's that !! is programmer talk, and ? is >> human talk. Ruby prefers human talk. >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/KND68A_wF8sJ. > > 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. > -- 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.
