Tuesday, May 6, 2008

File.new

File.new(file_name).close won't do what I intend to do, i.e. create a file. Instead File.new(file_name,'w').close does the trick. The problem is in the first case the second argument defaults to 'r' which means read. Its strange that parameter is defaulted to read only. When we create file we normally mean we are creating it to write something to the file. So it must default to 'w'.

No comments: