<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/FilePath/ends(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System8FilePathV4ends4withSbAC_tF"
  },
  "title" : "ends(with:)"
}
-->

# ends(with:)

Returns whether `other` is a suffix of `self`, only considering
whole path components.

```
func ends(with other: FilePath) -> Bool
```

## Discussion

Example:

```
let path: FilePath = "/usr/bin/ls"
path.ends(with: "ls")             // true
path.ends(with: "bin/ls")         // true
path.ends(with: "usr/bin/ls")     // true
path.ends(with: "/usr/bin/ls///") // true
path.ends(with: "/ls")            // false
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)