instance method
Pathname#join
(*::String | ::_ToStr | ::Pathname args) -> ::Pathname
join(*args)
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/pathname_builtin.rb, line 725
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