Issue #12194 has been updated by Benoit Daloze.


Using Pathname would already make this much nicer:

    Pathname(path).parent.parent

And less error prone than File.dirname if the path is not absolute.
Just my opinion, but I do not like this particular syntax.

----------------------------------------
Feature #12194: File.dirname optional parameter
https://bugs.ruby-lang.org/issues/12194#change-57574

* Author: Nobuyoshi Nakada
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
As talked at the last developers' meeting, I propose an addition of an optional parameter to `File.dirname`.

Often I see the code, like

```ruby
File.dirname(File.dirname(path)) # or
File.expand_path("../..", path)
```
which are not concise.

This proposal can make them as:

```ruby
File.dirname(path, 2)
```

https://github.com/ruby/ruby/compare/trunk...nobu:feature/dirname-level?expand=1



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>