Coercion of Strings to Integers

Coercion of Strings to Integers

Content #

:echom "hello" + 10

Vim会将非数字开头的字符串coerce成0,因此上面的结果会是10。

:echom "10hello" + 10

数字开头的字符串会coerce成整数,“10hello"的结果是10,最终结果是20。

:echom "hello10" + 10

非数字开头,“hello10"的结果是0,最终结果是10。

:echom "Hello, " + "world"

结果为0。

:echom 10 + "10.10"

Vim不会将string coerce成Floats. 结果为20.

From #