What makes Ruby so great?

Things you take for granted after using Ruby for awhile:

#This works:
topic.posts.length > 0
#The Ruby way:
topic.posts.any?

#This works:
topic.posts[topic.posts.length-1]
#The Ruby way:
topic.posts.last

#This works:
if!((foo != nil)&&(foo != ''))
#The Ruby way:
unless foo.blank?

Other nice things that I don’t care to come up with the harder version by hand for:

5.days.from_now
5.days.ago

note: day.* and .blank? only works in rails, not ruby out the box

Comments are closed.