Project

General

Profile

Actions

Misc #19155

closed

documentation of Pathname#join with absolute path

Added by colorbox (box color) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Assignee:
-
[ruby-core:111035]

Description

Pathname#join ignores previous directory name before absolute path

Is this intentional?

irb(main):002:0> require 'pathname'
=> true
irb(main):003:0> Pathname('/foo').join('bar', 'baz')
=> #<Pathname:/foo/bar/baz>
irb(main):004:0> Pathname('/foo').join('bar', '/baz')
=> #<Pathname:/baz>
irb(main):005:0> 

➜✗ ruby -v
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-darwin19]

I found that this behavior is intentional from test code but I cannot found reason.
https://github.com/ruby/pathname/blob/master/test/pathname/test_pathname.rb#L248-L261

There was no description of this behavior in the documentation.

Actions

Also available in: Atom PDF

Like0
Like0Like0