Project

General

Profile

Actions

Bug #13198

closed

Tempfile#size is nil when nothing is written, expected 0

Added by kyledrake (Kyle Drake) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:79459]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0