An extension to String using File.join

# An idea for a convenient extension to String in Ruby
class String
  def /(nxtpart)
    File.join(self, nxtpart)
  end
end

dirname = '/usr/local/bin'
cmd = 'gcc'

puts dirname/cmd

Here is the output:

/usr/local/bin/gcc

About this entry