Less Ugly way to concatenate strings
I have been working on a plotting library in mojo that is based on
gnuplot
. The code works but the string parts are extremely ugly:
So does anyone know a good way to concatenate strings? Does mojo have f-strings
yet?3 Replies
I made a naive/simple sprintf function if you want to give it a try. https://github.com/thatstoasty/gojo/blob/main/gojo/fmt/fmt.mojo
You could also try an external_call to
sprintf
. It's been awhile, but I do recall the external call also working for me
Could also use a string builder, if you're constructing a large string. For smaller strings, maybe just sprintf or concat would be better. https://github.com/thatstoasty/gojo/blob/main/gojo/strings/builder.mojoSo Mojo, doesn't have str.format and f-strings?
Not at the moment