Skip to main content
Log in

Mojo function

split

split[PathLike: PathLike, //](path: PathLike) -> Tuple[String, String]

Split a given pathname into two components: head and tail. This is useful for separating the directory path from the filename. If the input path ends with a separator, the tail component will be empty. If there is no separator in the path, the head component will be empty, and the entire path will be considered the tail. Trailing separators in the head are stripped unless the head is the root directory.

Parameters:

  • ​PathLike (PathLike): The type conforming to the os.PathLike trait.

Args:

  • ​path (PathLike): The path to be split.

Returns:

A tuple containing two strings: (head, tail).

Was this page helpful?