Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-swift latest

ControlNotificationStream.prefix(_:)

Returns an asynchronous sequence, up to the specified maximum length, containing the initial elements of the base asynchronous sequence.

Source and package
Qualified name
ControlNotificationStream.prefix(_:)
Declared in
ControlNotificationStream
Package
libtmux-swift
prefix(count: Int) -> AsyncPrefixSequence<Self>

Inherited from AsyncSequence.prefix(_:)

Description#

Use prefix(_:) to reduce the number of elements produced by the asynchronous sequence.

In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The prefix(_:) method causes the modified sequence to pass through the first six values, then end.

for await number in Counter(howHigh: 10).prefix(6) { print(number, terminator: " ") } // Prints "1 2 3 4 5 6 "

If the count passed to prefix(_:) exceeds the number of elements in the base sequence, the result contains all of the elements in the sequence.

  • Parameter count: The maximum number of elements to return. The value of count must be greater than or equal to zero.
  • Returns: An asynchronous sequence starting at the beginning of the base sequence with at most count elements.
Parameters
Esc

Type to search.

Reference previewOpen reference