int lua_isstring (lua_State *L, int index); This function returns 1 if the value with the given valid index is a string or a number (which is always converted to a string) and 0 otherwise. ( Source )
int lua_isstring (lua_State *L, int index);
This function returns 1 if the value with the given valid index is a string or a number (which is always converted to a string) and 0 otherwise. ( Source )
Is there a (more elegant) way to really prove if a given string is really a string and not a number in Lua? This function does not make any sense to me!
My first idea is to further examine the length of the string with
`if(string.len(String) > 1) {/* this must be a string */}`
... but that's not so good.
You can replace
lua_isstring(L, i)
which returns true for a string or number using
lua_type(L, i) == LUA_TSTRING
true .
,
lua_isnumber(L, i)
true , , ; ,
lua_type(L, i) == LUA_TNUMBER
( , lua_isstring_strict() lua_isnumber_strict().)
lua_isstring_strict()
lua_isnumber_strict()
!
Lua . , , , . . lua_isstring lua_tostring C - .
lua_isstring
lua_tostring
, LUA_NOCVTS2N / LUA_NOCVTN2S . , LUA_NOCVTN2S, lua_isstring false .
LUA_NOCVTS2N
LUA_NOCVTN2S
Source: https://habr.com/ru/post/1609494/More articles:HTML element does not remove jquery with name containing backslash - javascriptNodejs crypto.pbkdf2 result differs from CryptoJS.PBKDF2 - javascriptencode_www_form converts space to + instead of% 20 - ruby | fooobar.comWhat is the best way to perform computationally intensive tasks in Erlang without sacrificing scalability? - erlangHow do I call / execute a function from another component in the native response? - javascriptAWS device with espresso and JUnit4 - androidInclude and code on one line in C - cПовторное использование Struct для модулей в Elixir - elixirStream with threads - javaCpp how to disable a specific monitor? - c ++All Articles