Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Pathname#join
join(*args)
ext/pathname/lib/pathname.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/ext/pathname/lib/pathname.rb, line 416
def join(*args)
return self if args.empty?
result = args.pop
result = Pathname.new(result) unless Pathname === result
return result if result.absolute?
args.reverse_each {|arg|
arg = Pathname.new(arg) unless Pathname === arg
result = arg + result
return result if result.absolute?
}
self + result
end
Joins the given pathnames onto self to create a new Pathname object. This is effectively the same as using Pathname#+ to append self and all arguments sequentially.
Example
path0 = Pathname.new("/usr") # Pathname:/usr path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby # is the same as path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby path0 == path1 #=> true