Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Easier Path Construction Using Overloaded /

DZone's Guide to

Easier Path Construction Using Overloaded /

·
Free Resource
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}"


Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}