From: naruse@... Date: 2017-03-18T12:04:16+00:00 Subject: [ruby-core:80217] [Ruby trunk Bug#13198] Tempfile#size is nil when nothing is written, expected 0 Issue #13198 has been updated by naruse (Yui NARUSE). Backport changed from 2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONE ruby_2_4 r58013 merged revision(s) 57972. ---------------------------------------- Bug #13198: Tempfile#size is nil when nothing is written, expected 0 https://bugs.ruby-lang.org/issues/13198#change-63651 * Author: kyledrake (Kyle Drake) * Status: Closed * Priority: Normal * Assignee: Glass_saga (Masaki Matsushita) * Target version: * ruby -v: * Backport: 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONE ---------------------------------------- ~~~ ruby require 'tempfile' tmp = Tempfile.new tmp.write '' tmp.close tmp.size # => nil File.size(tmp.path) # => 0 ~~~ I'm not sure if this is actually a bug, but this behavior really surprised me. I think it would be better to return 0 in this scenario instead of nil, which would match the behavior of File. -- https://bugs.ruby-lang.org/ Unsubscribe: