I'm in a situation where I have a seq[char], like so:
import sequtils
var s: seq[char] = toSeq("abc".items)
What's the best way to convert s back into a string (i.e. "abc")? Stringifying with $ seems to give "@[a, b, c]", which is not what I want.
The most efficient way is to write a procedure of your own.
import sequtils
var s = toSeq("abc".items)
proc toString(str: seq[char]): string =
  result = newStringOfCap(len(str))
  for ch in str:
    add(result, ch)
echo toString(s)
import sequtils, strutils
var s: seq[char] = toSeq("abc".items)
echo(s.mapIt(string, $it).join)
Join is only for seq[string], so you'll have to map it to strings first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With