Conversation
|
I'am confused, what's the difference between Edit: that's the same, |
|
@j8r I guess I do agree that it might be confusing. So in your case you can do I'd also like to see |
With |
|
But having I've added a deprecation for |
|
True @j8r, another solution would be to make Or add |
|
No @bew, because:
|
|
I vote to close this. There's nothing wrong with |
|
I think it's confusing, others can be too like me. Any good reason to have both? |
|
One returns a string, which is familiar and known from File.dirname, the other one returns a Path. Why force users to write to_s when they can simply get something with one method call? |
|
The user that is familiar with |
Co-Authored-By: Sijawusz Pur Rahnama <sija@sija.pl>
|
Yes, the result of
|
|
Maybe one day all paths would be represented as |
Here is the use case I faced, how to get the directory name?
With either
File.basename(File.dirname(Dir.current))or
Path.new(Path.new(Dir.current).dirname).basename.to_sor a mix of both.
One can also use this, but this isn't as clear nor as efficient:
Path.new(Dir.current).parts.last.lchopNow, one can do:
Path.new(Dir.current).dirname.basename.to_sand the root directory of the current one:
Path.new(Dir.current).dirname.dirname.basename.to_sIf a
Stringis wanted,#to_scan still be called.EDIT: There is already
Path#parent, deprecatingPath#dirname