---
title: "extracting(first:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/rawspan/extracting(first:)"
---

# extracting(first:)

Returns a span containing the initial bytes of this span, up to the specified maximum byte count.

## Declaration

```swift
func extracting(first maxLength: Int) -> RawSpan
```

## Parameters

- `maxLength`: The maximum number of bytes to return. maxLength must be greater than or equal to zero.

## Return Value

Return Value A span with at most maxLength bytes.

## Discussion

Discussion If the maximum length exceeds the length of this span, the result contains all the bytes. The returned span’s first byte is always at offset 0; unlike buffer slices, extracted spans do not share their indices with the span from which they are extracted. note: O(1)
