Correct way have for-loop iteration up to number of only initialized array elements

2022-02-21 Thread ElegantBeef
`newSeqOfCap[int](70)` is just like `newSeq[int](70)` the only difference is the first only sets the capacity and it doesnt add any elements so it's an "empty" allocated sequence. So it avoids more allocation the same but `len` is `0`

Correct way have for-loop iteration up to number of only initialized array elements

2022-02-21 Thread mardiyah
worried get reallocation process, is the same as nr=ew Seq it'll avoid reallocation cost ?

Correct way have for-loop iteration up to number of only initialized array elements

2022-02-21 Thread dwin
Use `newSeqOfCap` instead of newSeq var d = newSeqOfCap[array[2, string]](70) d.add ["foo", "bar"] d,add ["moo", "dar"] for u in d: ... Run

Correct way have for-loop iteration up to number of only initialized array elements

2022-02-20 Thread mardiyah
How to limit `for loop` iteration up to number of only initialized or filled array elements var d = newSeq[ array[2,string]](70) d[0] = ["foo", "bar"] d[1] = ["moo", "dar"] for u in d : # ... so on # will loop 70