End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Pathname#/
/(other)
ext/pathname/lib/pathname.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/ext/pathname/lib/pathname.rb, line 354
def +(other)
other = Pathname.new(other) unless Pathname === other
Pathname.new(plus(@path, other.to_s))
end
Alias of #+
Appends a pathname fragment to self to produce a new Pathname object. Since other is considered as a path relative to self, if other is an absolute path, the new Pathname object is created from just other.
Example
p1 = Pathname.new("/usr") # Pathname:/usr p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd # / is aliased to +. p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
This method doesn’t access the file system; it is pure string manipulation.