---
title: "push(_:)"
framework: system
role: symbol
role_heading: Instance Method
path: "system/filepath/push(_:)"
---

# push(_:)

If other does not have a root, append each component of other. If other has a root, replaces self with other.

## Declaration

```swift
mutating func push(_ other: FilePath)
```

## Discussion

Discussion This operation mimics traversing a directory structure (similar to the cd command), where pushing a relative path will append its components and pushing an absolute path will first clear self’s existing components. Example: var path: FilePath = "/tmp" path.push("dir/file.txt") // path is "/tmp/dir/file.txt" path.push("/bin")         // path is "/bin"
