Issue #10121 has been updated by Lucas Buchala.


Now that Ruby got a Dir.empty? method, do you think it makes sense to add a File.empty? as an alias for File.zero? ?

Then, one would be able say things like this, in a single step:

~~~
files_and_dirs.reject(&:empty?)
~~~

(I didn't know if it was worth opening a new issue for this simple suggestion, so I just appended it here, since I see Dir.empty? and File.empty? as related methods, somehow)


----------------------------------------
Feature #10121: Dir.empty?
https://bugs.ruby-lang.org/issues/10121#change-57033

* Author: Robert A. Heiler
* Status: Closed
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
On IRC someone asked how to find out if a directory is empty or not, from within ruby.

It seems as if there was no simple way.

I suggest adding `Dir.empty?`

On IRC, someone else suggested this:

~~~ruby
Dir.entries(dir).size == 2
~~~

I do not know if there are better ways but possibly that could
be used for a `Dir.empty?` functionality?



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