How to concatenate Strings in a loop #2182
Unanswered
subramanian0331
asked this question in
Q&A
Replies: 1 comment
-
In CUE all concrete values are final, so you cannot concatenate. However, it seems like you can use strings.Join: import "strings"
cluster: {
lab1: "val1"
lab2: "val2"
lab3: "val3"
}
payload: {
final: strings.Join([ for k, _ in cluster {k}], "") // Results in "lab1lab2lab3".
} When creating issues and/or discussion, I would suggest you clearly show what you expect/want to achieve, along with your examples. Also, for future reference, here is a guide for formatting markdown in GitHub. This will be useful to better format issues/descriptions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to concatenate string as i traverse through a loop.
`
cluster:{
lab1:"val1"
lab2:"val2"
lab3: "val3"
}
payload:{
final : string
for key,val in cluster{
key + final
}
}
`
Beta Was this translation helpful? Give feedback.
All reactions