Skip to content

Asserting/setting individual list element contents #1706

Answered by myitcv
jpluscplusm asked this question in Q&A
Discussion options

You must be logged in to vote

I would do something like this:

import "list"

l: 10

// Establsh a list of length l
x: [for i in list.Range(0, l, 1) { _ }]

// Assert that the element at index 5 is 4
x: [for i in list.Range(0, l, 1) { if i == 5 { 4 } }]

Playground link

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jpluscplusm
Comment options

You must be logged in to vote
0 replies
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