---
title: lastComponent
framework: system
role: symbol
role_heading: Instance Property
path: system/filepath/lastcomponent
---

# lastComponent

Returns the final component of the path. Returns nil if the path is empty or only contains a root.

## Declaration

```swift
var lastComponent: FilePath.Component? { get }
```

## Discussion

Discussion Note: Even if the final component is a special directory (. or ..), it will still be returned. See lexicallyNormalize(). Examples: Unix: /usr/local/bin/ => bin /tmp/foo.txt    => foo.txt /tmp/foo.txt/.. => .. /tmp/foo.txt/.  => . /               => nil Windows: C:\Users\                    => Users C:Users\                     => Users C:\                          => nil \Users\                      => Users \\?\UNC\server\share\bar.exe => bar.exe \\server\share               => nil \\?\UNC\server\share\        => nil
