Humanity

Edit the world by your favorite way

単項+演算子とstr2nr()の違い

str2nr()は常に文字列を10進数で評価するみたいだけど、
単項+演算子は文字列を8進数で評価したり10進数で評価したり16進数で評価したりする。

command! -nargs=+ Assert if !(<args>) | echoerr 'assertion failure' | endif

Assert str2nr("10") ==# 10
Assert str2nr("010") ==# 10
Assert str2nr("0x10") ==# 0

Assert +"10" ==# 10
Assert +"010" ==# 8
Assert +"0x10" ==# 16