DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

A Replacement For Ruby's File.join

08.20.2006
| 5705 views |
  • submit to reddit
        File.join is ugly, there I've said it. So how about being able to replace this:

require File.join(LOAD_PATH, 'foobar')

With this:

require LOAD_PATH/:foobar

Trivial, really:

class String
  def /(o)
    File.join(self, o.to_s)
  end
end
    

Comments

Nic Williams replied on Thu, 2006/04/20 - 8:32am

That's brilliant! I love changing the language :)