What happens when you run this code? ``` require 'pathname' require 'tempfile' def make_pathname(value = http://Tempfile.new ("log")) http://Pathname.new (value) end p = make_pathname FileUtils.touch(p) puts "File: #{p.file?}" GC.start puts "File: #{p.file?}" ```
-
Show this thread
-
If you said a "GC bug in Ruby" then I think you're right: ``` $ ruby scratch.rb File: true File: false ```
2 replies 0 retweets 0 likesShow this thread -
Replying to @schneems
I don't think that's a bug. I would be surprised if the name of a file retained the file
1 reply 0 retweets 0 likes -
Replying to @sgrif
I'm surprised that passing a value to a Pathname object does not retain the object.
1 reply 0 retweets 0 likes -
Replying to @schneems
I think we disagree on the expected behavior here, but IMO the problem is that the behavior isn't obvious. What if there was a way that we could express this in the signature of the method. An "ownership" system, you might call it.
1 reply 0 retweets 1 like
(This just gives me vibes of a talk I gave like 4 years ago about how ownership isn't optional, Rust is just giving you a way to express it)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.