---
title: "output(in:)"
framework: combine
role: symbol
role_heading: Instance Method
path: "combine/publisher/output(in:)"
---

# output(in:)

Publishes elements specified by their range in the sequence of published elements.

## Declaration

```swift
func output<R>(in range: R) -> Publishers.Output<Self> where R : RangeExpression, R.Bound == Int
```

## Parameters

- `range`: A range that indicates which elements to publish.

## Return Value

Return Value A publisher that publishes elements specified by a range.

## Discussion

Discussion Use output(in:) to republish a range indices you specify in the published stream. After publishing all elements, the publisher finishes normally. If the publisher completes normally or with an error before producing all the elements in the range, it doesn’t publish the remaining elements. In the example below, an array publisher emits the subset of elements at the indices in the specified range: let numbers = [1, 1, 2, 2, 2, 3, 4, 5, 6] numbers.publisher     .output(in: (3...5))     .sink { print("\($0)", terminator: " ") }

// Prints: "2 2 3"

## See Also

### Selecting specific elements

- [first()](combine/publisher/first().md)
- [first(where:)](combine/publisher/first(where:).md)
- [tryFirst(where:)](combine/publisher/tryfirst(where:).md)
- [last()](combine/publisher/last().md)
- [last(where:)](combine/publisher/last(where:).md)
- [tryLast(where:)](combine/publisher/trylast(where:).md)
- [output(at:)](combine/publisher/output(at:).md)
