diff options
author | Googler <noreply@google.com> | 2018-06-21 10:58:15 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-21 10:59:24 -0700 |
commit | 9594d5e8dc465bb4526a2f15a4b547de7e1324a7 (patch) | |
tree | 4d745b06f875ca7d2da6822e494816c85fd08e4f /site | |
parent | cbf33b778aa5353a11553ce590b51dac1a302a48 (diff) |
If a dictionary is used as a general set, the keys should be mapped to `True` instead of `None`.
dict has a get() method that defaults to `None`.
Checking for a key in the dictionary with get() will always return `None` in the given example. Using `True` is better.
RELNOTES: None.
PiperOrigin-RevId: 201551896
Diffstat (limited to 'site')
-rw-r--r-- | site/docs/skylark/depsets.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/site/docs/skylark/depsets.md b/site/docs/skylark/depsets.md index 0199fed9d3..570ac23211 100644 --- a/site/docs/skylark/depsets.md +++ b/site/docs/skylark/depsets.md @@ -313,16 +313,16 @@ will appear twice on the command line and twice in the contents of the output file. The next alternative is using a general set, which can be simulated by a -dictionary where the keys are the elements and all the keys map to `None`. +dictionary where the keys are the elements and all the keys map to `True`. ```python def get_transitive_srcs(srcs, deps): trans_srcs = {} for dep in deps: for file in dep[FooFiles].transitive_sources: - trans_srcs[file] = None + trans_srcs[file] = True for file in srcs: - trans_srcs[file] = None + trans_srcs[file] = True return trans_srcs ``` |