You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use coll.Pick() to filter out some values to generate a sub-map. The keys that I need are dynamically generated, and at first I thought I could just do something like
error calling Pick: wrong key type: must be string, got []string
I realized that the input was not supposed to be an array, rather just a bunch of strings in order. So I began trying to figure a way to unpack the array in-line, however, I think the function is still treating the space-delimited list as a single string?
{{ $resultMap := coll.Pick (conv.Join ($mapWithMyKeys | keys) " ") ($largerMap) }}
len: {{ len (keys $resultMap }} // <-- still evals to 0
I even tried quoting each member of the array, to no avail:
Hmm... Indeed this is because coll.Pick is designed only to handle a number of inline strings, not a slice. It should be fairly straightforward to add slice support though.
There isn't going to be a good workaround for this unfortunately. I'll enhance the coll.Pick function so it can support a slice.
I would like to use
coll.Pick()
to filter out some values to generate a sub-map. The keys that I need are dynamically generated, and at first I thought I could just do something likebut I kept getting an error :
I realized that the input was not supposed to be an array, rather just a bunch of strings in order. So I began trying to figure a way to unpack the array in-line, however, I think the function is still treating the space-delimited list as a single string?
I even tried quoting each member of the array, to no avail:
am I missing something obvious here?
I have made absolutely certain that the keys I'm filtering on do exist in the target map.
edit: upon trying some more debugging, i realise the above code snippet ends up preserving the backslashes to escape the quotes:
This is a result of the
quote
function quoting the entire string.When I try it by using
printf
:at least the keys print out in quotes:
but still cannot be parsed as multiple keys, and instead still returns 0 matches from the
coll.Pick()
call.The text was updated successfully, but these errors were encountered: