Skip to content

How to generate a range of “int“ #1324

Answered by verdverm
mNantern asked this question in Q&A
Discussion options

You must be logged in to vote

If you already have your objects in a list, you can unify the id into the object after string interpolation, in a list comprehension

refd: [ for i, obj in objs { obj & { refId: "\(i)" } }]

Use refId: "\(i+1)" if you want to start indexing at 1

https://cuelang.org/play/?id=ciMZWAwEWBK#cue@export@cue

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mNantern
Comment options

Comment options

You must be logged in to vote
1 reply
@mNantern
Comment options

Answer selected by mNantern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants