Iteration produces unexpected number of elements #439
-
I am writing a policy that looks for given annotations on a K8s object and compares them to a list of required annotations to see if a required annotation is missing. The code can be found here. I've tried two different ways:
and
They both have the desired outcome. However, in the first case, What's happening here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I believe the misunderstanding might be in the meaning of r := required[_]
missing := r; not r in provided It does not constitute a restriction or WHERE-clause, or the RHS of a comprehension. It merely is the same as a line-break. So if you look at it like that r := required[_]
missing := r
not r in provided it would make sense that I believe you might be looking for a set comprehension here, like missing := { r | r := required[_]; not r in provided } or, equivalently, missing := { r | some r in required; not r in provided } |
Beta Was this translation helpful? Give feedback.
I believe the misunderstanding might be in the meaning of
;
inIt does not constitute a restriction or WHERE-clause, or the RHS of a comprehension. It merely is the same as a line-break. So if you look at it like that
it would make sense that
missing
has the same number of elements as some element ofrequired
. Try adding aprint(missing)
and you'll find thatmissing
is a string,"repository
, for whichcount()
returns the number of characters, 10.I believe you might be looking for a set comprehension here, like
or, equivalently,
missing := …