Hi, Ruby 2.4 introduced `Pathname#empty?` which delegates to `File#empty?` and `Dir#empty?`.
This caused a surprise in our code base, where we have this guard clause: def initialize(storage_path) raise ArgumentError, "no storage path configured" unless storage_path.present? # ... end where `storage_path` points to a directory and is constructed via `Rails.root.join("data/foo/bar").tap(&:mkpath)`. We've changed the guard to `if storage_path.nil?` as a workaround, but I still find it surprising that an existing path on disk is not `#present?`. foo = Pathname.new("/tmp").join(SecureRandom.uuid) foo.exist? #=> false foo.present? #=> false foo.mkpath foo.exist? #=> true foo.present? #=> false Now, I don't know how strict the negation of `Object#present?` (i.e. `== !blank?`) is intended be, or else I'd have opened an issue/PR on GitHub and asked for another core extension, in the likes of if Pathname.instance_methods.include?(:empty?) class Pathname alias present? exist? end end but that would lead to an instance beeing simultaneously `#blank?` and `#present?` (considering an `#empty?` directory ought to be `#blank?`). So... what do you think? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.