tnewseqofcap.nim 305 B

1234567891011121314
  1. const
  2. foo = @["aaa", "bbb", "ccc"]
  3. proc myTuple: tuple[n: int, bar: seq[string]] =
  4. result.n = 42
  5. result.bar = newSeqOfCap[string](foo.len)
  6. for f in foo:
  7. result.bar.add(f)
  8. # It works if you change the below `const` to `let`
  9. const
  10. (n, bar) = myTuple()
  11. doAssert bar == @["aaa", "bbb", "ccc"]