Guest User

Untitled

a guest
Jul 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. require 'tempfile'
  2. class FileWrapper
  3. def create_tempfile_with_a_block
  4. @file = Tempfile.new('foo')
  5. @file.close
  6. end
  7. def create_tempfile
  8. create_tempfile_with_a_block {}
  9. end
  10. end
  11.  
  12. FileWrapper.new.create_tempfile
  13. GC.start
  14. file_count = ObjectSpace.each_object(FileWrapper){|o| puts o.inspect}
  15. puts "Expected 0 files, found #{file_count}"
Add Comment
Please, Sign In to add comment