Skip to content

Commit b656888

Browse files
committed
Documentation
1 parent 23f866e commit b656888

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ struct SortedDifference<LeftSequence, RightSequence, ID>: Sequence where
9595
}
9696

9797
// Prints:
98-
// - common(1, 1)
99-
// - left(2)
98+
// - common(Left(id: 1), Right(id: 1))
99+
// - left(Left(id: 2))
100+
struct Left { var id: Int }
101+
struct Right { var id: Int }
100102
for change in SortedDifference(
101-
left: [1, 2],
102-
identifiedBy: { "\($0)" },
103-
right: ["1"],
104-
identifiedBy: { "\($0)" })
103+
left: [Left(id: 1), Left(id: 2)],
104+
identifiedBy: { $0.id },
105+
right: [Right(id: 1)],
106+
identifiedBy: { $0.id })
105107
{
106108
print(change)
107109
}

Sources/SortedDifference/SortedDifference.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ public struct SortedDifference<LeftSequence, RightSequence, ID>: Sequence where
4141
/// For example:
4242
///
4343
/// // Prints:
44-
/// // - common(1, 1)
45-
/// // - left(2)
44+
/// // - common(Left(id: 1), Right(id: 1))
45+
/// // - left(Left(id: 2))
46+
/// struct Left { var id: Int }
47+
/// struct Right { var id: Int }
4648
/// for change in SortedDifference(
47-
/// left: [1, 2],
48-
/// identifiedBy: { "\($0)" },
49-
/// right: ["1"],
50-
/// identifiedBy: { "\($0)" })
49+
/// left: [Left(id: 1), Left(id: 2)],
50+
/// identifiedBy: { $0.id },
51+
/// right: [Right(id: 1)],
52+
/// identifiedBy: { $0.id })
5153
/// {
5254
/// print(change)
5355
/// }

0 commit comments

Comments
 (0)