-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Path#empty? #9137
Add Path#empty? #9137
Conversation
I'm not sure I understand the definition of |
Empty means |
|
Because it's semantically equivalent to |
I'd rather say the opposite, Also, note the Ruby's
|
Do you have a suggestion for a better name? IMO empty is pretty much self explanatory and the typical term for this. |
I'm not sure we need this method at all, since you just came up with that with no good usecase, there was no one requesting, or even mentioning this before, so...
Well, for sure it ain't for me, hence my question. I don't think I've seen such method anywhere else. |
The description has always been there in the doc comment for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is picking Path#empty?
becuase String#empty?
and @name : String
.
As @Sija pointed, ruby semantics for Path is another valid use case for what Path#empty?
can mean.
I'm not sure we need a public api for this, since I guess we can check a_path.normalize == Path["."].normalize
.
If we don't need a public api, we can pick whatever name and keep the code cleanup in each_parent
.
If we need a public api, #idempotent?
, #identity?
sounds more appealing to me and does not add noise to the fact that Path["."]
is considered so (as it does #empty?
)
Agreed, "." doesn't look like empty to me. |
No, it's not. I actually copied that name from boost. But fine, I'll make the method private. |
This adds a new query method to
Path
to tell whether it's empty.The existing definition of empty is expanded to also include
"."
which hasn't been covered before but is actually the normalized form of""
.