This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: Fun with File.join
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
I'll give you a hint: none of these raise a TypeError. Ok, now here are the answers:
File.join("") # "" - ok
File.join("", "") # "/" - huh?
File.join(nil) # "" - expected a TypeError
File.join(nil, nil) # "/" - wha..? again, expected a TypeError
File.join(1,2) # "1/2" - expected a TypeError
File.join("/") # "/" - hrm, ok, but...
File.join("/", "/") # "//" - could be smarter
Calling .to_s on all the array arguments strikes me as inconsistent vis-a-vis File.dirname, File.basename, and File.extname, but I guess it's liveable.
Update: Portion of post about Ruby source code being confused was deleted. It turns out that the separator, for good or ill, is hard coded to '/'.