I would like a working version of this:
let x = "a" ^ 0;;
The (^) binary operator concatenates two strings.
Concatenates strings and returns the concatenated string. $concat has the following syntax: { $concat: [ <expression1>, <expression2>, ... ] } The arguments can be any valid expression as long as they resolve to strings.
As you undoubtedly noticed, you can only concatenate strings with other strings - not integers. So you'll have to convert your integer to a string before you can concatenate it. If the integer is really hard coded like in your example, you can just write "0"
instead of 0
(in fact in your example you can just write "a0"
and not concatenate anything at all).
If the integer is not a constant, you can use string_of_int
to convert it to a string. So this will work:
let x = "a" ^ string_of_int my_integer
You can also use the usual printf functions but it is much slower:
let x = Printf.sprintf "a%d" my_integer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With