[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>

Hi,

15 messages 2017/02/15

[ruby-core:79459] [Ruby trunk Bug#13198] Tempfile#size is nil when nothing is written, expected 0

From: kyle@...
Date: 2017-02-06 19:03:57 UTC
List: ruby-core #79459
Issue #13198 has been reported by Kyle Drake.

----------------------------------------
Bug #13198: Tempfile#size is nil when nothing is written, expected 0
https://bugs.ruby-lang.org/issues/13198

* Author: Kyle Drake
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
~~~ 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next