present? is killing Ruby

I don’t mean this literally, but have you ever seen code like this:

post = Post.first
if post.present?

If you think about it, the present? is not necessary. It’ll be either nil or it will be a record. But we don’t usually even think about it and we just use it everywhere. I’m talking about Rails developers.

What do you think, is it being abused?

On a side note, I would love to see Coffeescript’s existential operator in Ruby. It could actually be implemented with method missing, except for local variables.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s