Mega Code Archive

 
Categories / Ruby / Method
 

If theres a block, pass in the file and close the file when it returns

class File     def File.my_open(*args)       result = file = File.new(*args)              if block_given?         result = yield file         file.close       end       return result     end   end