tnewseqofcap.nim 332 B

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