RandomAccessCollection

extension RandomAccessCollection where Index == Int

Available where Index == Int

  • Splits the given sequence up into slices that contain maxLength elements. The last slice can contain less than maxLength elements.

    Precondition

    sliceLength > 0

    Declaration

    Swift

    @inlinable
    public func split(maxLength: Int) -> [SubSequence]

    Parameters

    maxLength

    number of items in one slice. Must be greater than 0.

    Return Value

    Slices with maxLength elements each. The last slice can contain less than maxLength elements.