Эта страница ещё не переведена, поэтому показана на английском. Помогите с переводом

difference

Returns the elements of the second iterable that do not occur in the first — argument order matters.

Iterable<A> difference<A>(Iterable<A> iterable1, Iterable<A> iterable2) FxAsyncIterable<A> differenceAsync<A>(FxAsyncIterable<A> iterable1, FxAsyncIterable<A> iterable2) Fx<T> Fx<T>.difference(Iterable<T> other) // chain: values of the chain not in other

Lecture

Read the signature carefully: difference(iterable1, iterable2) walks iterable2 and yields each of its elements that is not found in iterable1 (deduplicated, like uniq). iterable1 is only ever used as a membership set to test against — none of its own elements can appear in the output, and its own duplicates don't matter. This order is not symmetric: swapping the arguments produces a completely different (and generally different-length) result. A useful way to remember it: think of iterable1 as "the exclusion list" and iterable2 as "the list you're filtering."

Internally it's differenceBy((a) => a, iterable1, iterable2) — see differenceBy if you need to compare by a computed key instead of value equality.

There's no chain method for difference; it only exists as a data-first function (and its async counterpart). On the async side, the concurrency marker from .concurrent(n) applies to iterable2 — the exclusion set in iterable1 is always drained up front before results start flowing.

Demo 1 · Basics & argument order

Demo 2 · Async, with concurrency

Try it yourself

Exercise: use difference to find the tasks in allTasks that are not yet in completed.

Related: differenceBy — the same, by a computed key · intersection — keep the shared elements instead · uniq — dedupe a single iterable · includes — test membership in a single iterable