I think the current behavior is somewhat surprising, but not because of
Rails, it is because of Ruby.

The first paragraph of Pathname in the official docs says:

*Pathname represents the name of a file or directory on the filesystem, but
not the file itself.*

Nice, since we are dealing with file names I would expect Pathname#empty?
to be like String#empty?

Problem is, Pathname actually has the String-like manipulation API one
would expect from the description, and also a whole lot of file and
directory API! This is later also acknowledged in the docs

*All functionality from File, FileTest, and some from Dir and FileUtils is
included, in an unsurprising way. It is essentially a facade for all of
these, and more.*


If you ask me, I don't really understand this API to be honest, but that is
the way it is.

So, who decides if #empty? should be interpreted String-wise or File-wise?
The Ruby team, and they have decided File-wise. Therefore, our expectacion
of #empty? being String-wise has to be corrected.

And after that conclusion, the fact that present? is consistent follows,
because it is documented that anything that is empty is blank, and that
present? is just a convenience negation of being blank.

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

Reply via email to