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
You’re currently reading “An extension to String using File.join,” an entry on Esoteric Ruby
- Published:
- October 18th 08:43 AM
- Updated:
- October 18th 08:50 AM
- Sections:
- Ruby
0 comments
Jump to comment form | comments rss [?]