On Friday, June 17, 2011 02:52:53 PM Michael Edgar wrote:
> On Jun 17, 2011, at 3:49 PM, Jeremy Bopp wrote:
> > According to the documentation for File.expand_path, all that is
> > required is that $HOME is set correctly.  It doesn't apparently use the
> > shell to figure this out.  Chad's method even works on Windows. :-)
> > 
> > I might simplify this just a tiny bit though:
> > 
> > File.expand_path("~/#{filename}")
> 
> I use File.join for such situations due to separator differences. Is this
> unnecessary for some reason?

I use File.join also -- well, actually, I look for opportunities to use the 
Pathname library instead. But on modern Windows, forward slashes work, too.

I had to explain this to people writing a Java program in which they hardcoded 
backslashes. Java's File library is a lot like Ruby's Pathname library, and 
you have to create a File object eventually anyway, but even if you ignore all 
that, forward slashes work fine!