String Interpolation With Integers And Sprintf
ReasonML's Printf
module
comes with a number of functions for formatting values of various types. The
sprintf
function allows for string interpolation.
It functions the same as fprintf
but instead of outputting the result to
some channel, it returns a string. It enforces type checking as well -- the
%i
is specifically for integers, so using that with a type other than an
integer will result in a compilation error.
See the Printf
docs for more
details.