Skip to main content
Log in

Mojo function

basename

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

Returns the tail section of a path.

basename("a/path/foo.txt") # returns "foo.txt"
basename("a/path/foo.txt") # returns "foo.txt"

Parameters:

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

Args:

  • path (PathLike): The path to retrieve the basename from.

Returns:

The basename from the path.