How to convert from single character to/from string in Nim?

This tutorials explains about how to concatenate Strings in Nim language.

Nim String Concatenate example

There are multiple ways, we do string append in NIM language.

  • using & operator

    & operator appends one string into end of another string.

var str = "one "
var str1 = "two "
var result= str & str1
echo result
  • using strutils join function strutils module has join procedure that joins the openarray of elements to append


func join(a: openArray[string]; sep: string = ""): string {.....}

Input: array of strings sep - is an separator that appends between each string

Here is an example

import strutils;
var result=join(["one", "two", "three"], " ")
echo result


one two three