From 9594d5e8dc465bb4526a2f15a4b547de7e1324a7 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 21 Jun 2018 10:58:15 -0700 Subject: 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 --- site/docs/skylark/depsets.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'site') 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 ``` -- cgit v1.2.3