aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java4
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} "