Never been to DZone Snippets before?

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

Easier path construction using overloaded / (See related posts)


Especially when writing rake tasks where a lot of path construction code is written the following overloading of the / operator makes the code more readable.


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

# and you can write
#   path = all/along/the/watch/tower
# instead of 
#   path = "#{all}/#{along}/#{the}/#{watch}/#{tower}"



You need to create an account or log in to post comments to this site.


Click here to browse all 4829 code snippets

Related Posts