How do you do string interpolation with variables in nim?

后端 未结 1 1195
一整个雨季
一整个雨季 2021-01-23 19:22

I\'ve seen that you can interpolate strings with fmt like so:

    let msg = \"hello\"
    echo fmt\"{msg}\\n         


        
相关标签:
1条回答
  • 2021-01-23 20:07

    Yes, see strutils.format.

    strutils also comes with the % operator which can be used like:

    let str = "$#, $#, $#"
    let interp = str % ["One", "Two", "Three"]
    echo(interp) # echos One, Two, Three
    
    0 讨论(0)
提交回复
热议问题