Search code examples
stringcharacterchaiscript

Chaiscript, how to convert a char to a string


I need to loop every characters of the string. Whether I use a for loop or a range, I get stuck with characters and I can't convert them back to a string.

var str = "abcd"

var a = str[0]
var b = str[1]

print(a.to_string())
print(join([a,b],""))

Output:

97
9798

How to I bring that back to a string?

Thank you


Solution

  • You can loop your string using str.Left(i). Then each loop your string becomes str.Right(str.size()-1)

    This returns a string.