diff options
author | 2017-07-19 19:50:22 +0200 | |
---|---|---|
committer | 2017-07-20 10:29:02 +0200 | |
commit | 54feda55ebf10198a979f4546f684fa8b51c6fb8 (patch) | |
tree | acaa5bb2acbb6bf66576e87479c654b8bcc5ac42 /src/main/java/com/google/devtools | |
parent | 978780d6d4432d46199331bd8dae34ce10dab067 (diff) |
Update documentation of `dict`, mention it's mutable.
RELNOTES: None.
PiperOrigin-RevId: 162505701
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java index 08318226b5..40c9c9ddb3 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java @@ -31,13 +31,15 @@ import javax.annotation.Nullable; "A language built-in type representating a dictionary (associative mapping). " + "Dictionaries may be constructed with a special literal syntax:<br>" + "<pre class=\"language-python\">d = {\"a\": 2, \"b\": 5}</pre>" + + "See also the <a href=\"globals.html#dict\">dict()</a> constructor function. " + "When using the literal syntax, it is an error to have duplicated keys. " + "Use square brackets to access elements:<br>" + "<pre class=\"language-python\">e = d[\"a\"] # e == 2</pre>" + "Like lists, they can also be constructed using a comprehension syntax:<br>" + "<pre class=\"language-python\">d = {i: 2*i for i in range(20)}\n" + "e = d[8] # e == 16</pre>" - + "See also the <a href=\"globals.html#dict\">dict()</a> constructor function. " + + "Dictionaries are mutable. You can add new elements or mutate existing ones:" + + "<pre class=\"language-python\">d[\"key\"] = 5</pre>" + "<p>Iterating over a dict is equivalent to iterating over its keys. The " + "<code>in</code> operator tests for membership in the keyset of the dict.<br>" + "<pre class=\"language-python\">\"a\" in {\"a\" : 2, \"b\" : 5} " |