---
title: removeLastComponent()
framework: system
role: symbol
role_heading: Instance Method
path: system/filepath/removelastcomponent()
---

# removeLastComponent()

In-place mutating variant of removingLastComponent.

## Declaration

```swift
@discardableResult mutating func removeLastComponent() -> Bool
```

## Discussion

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 "/"
