lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Asko Kauppi wrote:
[...]
Would it be hard to make 'string.find()' return true numbers (not strings with numerical contents, as now):

    local _,_, a,b= string.find( "42 world", "(%d+)%s+(.+)" )

    --now: "42","world"
    --then: 42,"world"

I believe this little change would be welcome, and not cause major headaches in applications (they now have 'tonumber()', which would become irrelevant but work the same).

Why do you need it? Lua will implicitly convert the numbers as needed.

a = "42"
print(a + 1)
-> 43

--
[insert interesting .sig here]