Created
          June 29, 2012 12:50 
        
      - 
      
- 
        Save dblack/3017739 to your computer and use it in GitHub Desktop. 
    weakref behavior
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | This is from the end of weakref.rb: | |
| if __FILE__ == $0 | |
| # require 'thread' | |
| foo = Object.new | |
| p foo.to_s # original's class | |
| foo = WeakRef.new(foo) | |
| p foo.to_s # should be same class | |
| ObjectSpace.garbage_collect | |
| ObjectSpace.garbage_collect | |
| p foo.to_s # should raise exception (recycled) | |
| end | |
| And this is the output from running it (no exception raised): | |
| "#<Object:0x000001010b3ea0>" | |
| "#<Object:0x000001010b3ea0>" | |
| "#<Object:0x000001010b3ea0>" | |
| Any thoughts on why? I haven't yet delved deeply into the code. | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment