You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checking whether a file is empty in Ruby was always a bit weird:
You can use File.zero? (class method of File)
You can use file.size == 0 or file.size.zero?
For some reason Ruby has always shied away from adding an empty? method to file objects (you can't do file.empty?, but at least Ruby 2.4 added an File.empty? method that is an alias of File.zero? and reads better. It'd be nice (and easy) to have some cop promoting the use of File.empty?.
The text was updated successfully, but these errors were encountered:
Checking whether a file is empty in Ruby was always a bit weird:
File.zero?
(class method ofFile
)file.size == 0
orfile.size.zero?
For some reason Ruby has always shied away from adding an
empty?
method to file objects (you can't dofile.empty?
, but at least Ruby 2.4 added anFile.empty?
method that is an alias ofFile.zero?
and reads better. It'd be nice (and easy) to have some cop promoting the use ofFile.empty?
.The text was updated successfully, but these errors were encountered: