Instance MethodSwift

difference(from:by:)

Returns the difference needed to produce this collection’s ordered elements from the given collection, using the given predicate as an equivalence test.

  • iOS 13.0+
  • macOS 10.15+
  • tvOS 13.0+
  • watchOS 6.0+
func difference<C>(from other: C, by areEquivalent: (C.Element, Self.Element) -> Bool) -> CollectionDifference<Self.Element> where C : BidirectionalCollection, Self.Element == C.Element

Parameters

other

The base state.

areequivalent

A closure that returns a Boolean value indicating whether two elements are equivalent.

Returns

The difference needed to produce the receiver’s state from the parameter’s state.

Overview

This function does not infer element moves. If you need to infer moves, call the inferringMoves() method on the resulting difference.