I love anything that can be done to clean up source code and make it more readable.  So, when I came upon this post, I was pretty excited.  This is precisely the kind of thing I love.

I have never felt good about ‘file separator’ strings b/c of their ugliness and verbosity.

In Java we have:

String path = "lib"+File.separator+"etc";

And in Ruby a popular method is:

path = File.join("lib","etc")

Now, by overloading the ‘/’ operator on a String in Ruby:

class ::String

  def /(str_to_join)
    File.join(self, str_to_join)


We can now write:

path = 'lib'/'src'/'main'