Issue #14136 has been updated by Hanmac (Hans Mackowiak).


nobu (Nobuyoshi Nakada) wrote:
> I'd suggest `File.empty?` instead.

`File.empty?` might not always work because you might want lstat or other stat objects

but `File::Stat#size?` might be interesting, it does return nil on empty size

@mikegee i think you want this: `File::Stat#zero?`

----------------------------------------
Feature #14136: Implement #empty? on more classes
https://bugs.ruby-lang.org/issues/14136#change-68035

* Author: mikegee (Michael Gee)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hi Ruby Friends!

Rubocop prefers `#empty?` over `length == 0` and `size == 0`, which is great for `String`, `Array`, `Hash`, etc. It would be nice if more classes implemented `#empty?` for consistency.

See related discussion at https://github.com/bbatsov/rubocop/issues/2841.

I started this work at https://github.com/ruby/ruby/pull/1759

Thanks!



-- 
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>