import strformat, jsffi
var
obj = JsObject{field: 1}
s = obj.field.to(cstring)
Why does this work?
var f1 = s & " is a string".cstring
console.log(f1)
But this doesn't:
var f2 = fmt"{s} is a string".cstring
console.log(f2)
I get this error in the console: "Uncaught RangeError: Invalid array length"
I would appreciate it if someone could explain this to me!
Thank you for your reply!
I'm still confused though.
I can do this and strformat seems to have no issue with cstring
import jsffi, strformat, jsconsole
var
obj = JsObject{field: "1".cstring}
s = obj.field.to(cstring)
var f = fmt"{s} is a string".cstring
console.log(f)
If I try to convert to a string:
var
obj = JsObject{field: 1}
s = obj.field.to(string)
var f = fmt"{s} is a string".cstring
console.log(f)
I get this error: Uncaught TypeError: src_33557137.slice is not a function