# `GSLayer segmentAtIndexPath:`

*Instance Method*

Returns the segment at an index path.

## Declaration

```swift
func segment(at indexPath: IndexPath) -> GSPathSegment?
```

```objc
- (GSPathSegment *) segmentAtIndexPath:(NSIndexPath *) indexPath;
```

```python
segmentAtIndexPath_(indexPath: NSIndexPath) -> GSPathSegment
```

## Discussion

The first index is the linear path index and the last index is the segment node index in that path. Returns `nil` if the first index does not refer to a path.

## See Also

### Segments

- [`GSLayer segments`](/Core/GlyphsCore/GSLayer/segments) — The path segments from all path shapes in linear shape order.

