From: Jamey Cribbs Date: 2007-06-04T23:20:01+09:00 Subject: Re: Deleting a file - is there a less clumsy way to do this? Ronald Fischer wrote: > In my application, I often have blocks of code, where during preparation > code, I need to make sure that certain files do not exist (in practice, > this might be files left over from a previous run, which I didn't want > to have erased earlier). Basically, I am doing something like this: > > if File.exist?(filename) > File.unlink(filename) > end > You can get it down to one line by doing this: File.delete(filename) if File.exist?(filename) That doesn't look so bad. :-) Jamey