Things to do before I die

Here I am again talking about my imminent death, but hey I really want to know that by the time I’m done my list of TO DOs y finished and the only way I tend to do things is when I write them down. So here it is as of the year 2012:

  • Learn how to use a bow and arrow
  • Go to a Green Day concert
  • Go to a SXSW festival
  • Go to a ACL
  • Buy a house in the city
  • Buy a house on the beach
  • Buy a Mustang
  • Get a masters degree in computer science or something of the sort
  • Get married
  • Buy a house with a basement and turn it into a theater room
  • Attend a ruby conference
  • Live in a house, a very big house in the country
  • Have 4 children and name them after the Teenage Mutant Ninja Turtles (not likely but dare to dream)
  • Learn to cook
  • Taste a salad

This list will continue to grow I know, but for the time being I have a lot of stuff to keep me busy for a while.

Just try!

I was reading the other day a post on “What’s new” with Rails and I came across a clever little method that is added to the Object class: Object#try. It works in a very simple way, it checks to see if an object responds to a method if it doesn’t well it fails misserably and does nothing but no errors are thrown. For those of you that love exceptions you are not going to like this.

I tried a very simple and probably is not the way that Rails implemented it but it does the job, a very small job since it doesn’t handle blocks or anything of the sort. Keep in mind that I came up with this in 0.005 seconds so it’s probably wrong in some very serious ways.

class Object
  def try method
   if respond_to? method
      send method
   else
     self
   end
  end
end

"hello".try(:hello) #=> "hello"
"hello".hello #=> NoMethodError
"1".try(:hello).try(:to_i) #=> 1

I’m sure Rails version is more complete than mine. I would expect it to handle arguments and blocks. If it doesn’t then what are they thinking!

And as Ben Parker once said, with great power comes great responsibility. I do see some places where this is going to cause more pain than relief