Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: sdk/lib/core/set.dart

Issue 1682013002: Documentation cleanups. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/date_time.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/set.dart
diff --git a/sdk/lib/core/set.dart b/sdk/lib/core/set.dart
index 2c6b52417de05453bbd6670f27eef09cf4fca7dd..984c41601ddac0295a55808f85ba3e7362c809d7 100644
--- a/sdk/lib/core/set.dart
+++ b/sdk/lib/core/set.dart
@@ -88,9 +88,25 @@ abstract class Set<E> extends Iterable<E> implements EfficientLength {
bool contains(Object value);
/**
- * Adds [value] into the set. Returns `true` if [value] was added to the set.
- *
- * If [value] already exists, the set is not changed and `false` is returned.
+ * Adds [value] to the set.
+ *
+ * Returns `true` if [value] (or an equal value) was not yet in the set.
+ * Otherwise returns `false` and the set is not changed.
+ *
+ * Example:
+ *
+ * var set = new Set();
+ * var time1 = new DateTime.fromMillisecondsSinceEpoch(0);
+ * var time2 = new DateTime.fromMillisecondsSinceEpoch(0);
+ * // time1 and time2 are equal, but not identical.
+ * Expect.isTrue(time1 == time2);
+ * Expect.isFalse(identical(time1, time2));
+ * set.add(time1); // => true.
+ * // A value equal to time2 exists already in the set, and the call to
+ * // add doesn't change the set.
+ * set.add(time2); // => false.
+ * Expect.isTrue(set.length == 1);
+ * Expect.isTrue(identical(time1, set.first));
*/
bool add(E value);
« no previous file with comments | « sdk/lib/core/date_time.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698