Mungomash

Chad Dalton - hacker

Add Method to Existing Class in Ruby

| Comments

Classes are not locked down in Ruby. If you wanted to add the firstName method to the String class, you could call that method on any string. For example …

1
"Chad Dalton".firstName

As with most Ruby, the code is simple and straight-forward. Here is code that allows you to write 2.weeks.ago …

Comments