Hi, I'm trying to dynamically create a seq[seq[string]]. Below is what I came up with, and while it works, I'm wondering if it's the "right" way. At run time, the dimension sizes are known, so is an array more appropriate/efficient? Thanks for any insights you can provide.
var rows = 2
var cols = 3
var s = newSeq[seq[string]](rows)
for row in 0..<rows:
s[row] = newSeq[string](cols)
for col in 0..<cols:
s[row][col] = "test" & $row & $col
You can combine the initialization into a single call
import seqUtils
var rows = 2
var cols = 3
var s = newSeqWith(rows, newSeq[string](cols))
for row in 0..<rows:
for col in 0..<cols:
s[row][col] = "test" & $row & $col
echo s