Contents

removeLastComponent()

In-place mutating variant of removingLastComponent.

Declaration

@discardableResult mutating func removeLastComponent() -> Bool

Discussion

If self only contains a root, does nothing and returns false. Otherwise removes lastComponent and returns true.

Example:

var path = "/usr/bin"
path.removeLastComponent() == true  // path is "/usr"
path.removeLastComponent() == true  // path is "/"
path.removeLastComponent() == false // path is "/"