Array

extension Array
extension Array where Element: NSAttributedString
  • Seealso

    Array.filter(_:)

    Declaration

    Swift

    public func filterKeepingFirstAndLast(_ isIncluded: (Element) throws -> Bool) rethrows -> [Element]
  • Seealso

    Array.split(maxSplits:omittingEmptySubsequences:whereSeparator:)

    Declaration

    Swift

    public func splitExceptAtStartAndEnd(maxSplits: Int = .max, omittingEmptySubsequences: Bool = true, whereSeparator isSeparator: (Element) throws -> Bool) rethrows -> [ArraySlice<Element>]
  • Conditionally remove each element depending on the elements immediately preceding and following it.

    Declaration

    Swift

    mutating func removeSeparators(where shouldBeRemoved: (Element?, Element, Element?) throws -> Bool) rethrows

    Parameters

    shouldBeRemoved

    A closure that is called once for each element in reverse order from last to first. The closure accepts the following arguments: the preceding element in the (unreversed) array, the element itself, and the following element in the (unreversed) array.

  • Returns a new attributed string by concatenating the elements of the array, adding the given separator between each element.

    Declaration

    Swift

    func joined(separator: NSAttributedString = .init()) -> NSAttributedString