Hi,


I'd greatly appreciate feedback on the following code.


def create_files
     names_array = self.read_names #another method in my class

     while names_array.length != 0
       name = names_array.pop
       File.open( name, "w" ) { |f| f.puts "File is no longer empty" }
     end

x.create_files


Which results in:

C:/Scripts/Ruby/file_gen.rb:34:in `initialize': Invalid argument - echo (Errno
::EINVAL)
         from C:/Scripts/Ruby/file_gen.rb:34:in `open'
         from C:/Scripts/Ruby/file_gen.rb:34:in `create_files'
         from C:/Scripts/Ruby/file_gen.rb:42

The array contains the strings 'alpha' through 'foxtrot' and before  
producing the error above the file 'foxtrot' is created. So the logic  
works once before failing.

When I pull this code out of the class definition it works perfectly  
and creates
a file for every name in the array. What noob mistakes am I making?


Thanks,

S.