toPath

fun List<String>.toPath(addPrefix: Boolean = true, addTrailing: Boolean = true, separator: CharSequence = "/"): String

Joins this list of strings into a path with configurable leading and trailing separators.

Extension function on List<String>. Every leading separator on an element after the first, and every trailing one on an element before the last, is removed, and elements left empty are skipped, so elements never produce doubled separators.

Return

the joined path string

Parameters

addPrefix

whether to prepend separator to the first element if it lacks one (default true)

addTrailing

whether to append separator to the last element (default true)

separator

the path separator (default "/")