Correctly join self with subpath using the directory separator.

Using a standard "{self}/{path}" does not work in the following cases:

  • self is empty.
  • path starts with '/'.

This method ensures that the join is valid.

var hello = "hello".to_path
assert (hello/"world").to_s   == "hello/world"
assert ("hel/lo".to_path / "wor/ld").to_s == "hel/lo/wor/ld"
assert ("".to_path / "world").to_s == "world"
assert (hello / "/world").to_s  == "/world"
assert ("hello/".to_path / "world").to_s  == "hello/world"

Property definitions

core $ Path :: /
	# Correctly join `self` with `subpath` using the directory separator.
	#
	# Using a standard "{self}/{path}" does not work in the following cases:
	#
	# * `self` is empty.
	# * `path` starts with `'/'`.
	#
	# This method ensures that the join is valid.
	#
	#     var hello = "hello".to_path
	#     assert (hello/"world").to_s   == "hello/world"
	#     assert ("hel/lo".to_path / "wor/ld").to_s == "hel/lo/wor/ld"
	#     assert ("".to_path / "world").to_s == "world"
	#     assert (hello / "/world").to_s  == "/world"
	#     assert ("hello/".to_path / "world").to_s  == "hello/world"
	fun /(subpath: String): Path do return new Path(path / subpath)
lib/core/file.nit:643,2--658,64