Is there a syntax to cast from one character type for another? For example can you cast from a char to an int?
I tried:
let my_var = (int)some_char
It is not valid code.
The answer is no. There is no general syntax to cast from one type to another. There are unique ways of converting to different types, but no universal casting syntax.
You can do this in a round about way by first casting the float to a string then casting it to number for example:
echom str2nr(string(log10(200)))
Hope this helps people searching in the future.
Vim automatically converts a string to a number when it is looking for a number.
If you want ASCII char conversion instead, seechar2nr()
andnr2char()
.str2nr
function.:help variables