R
R
raiboon2015-12-29 12:20:13
Lua
raiboon, 2015-12-29 12:20:13

How to check if a value is empty in lua?

It's kind of stupid. Like, if there is no value, then nil.
But here I use openresty-redis - if there is no value in the radish, userdata "nil" will be returned, which is not nil, but true, and if you're not lucky, it will also throw an error - because the data type is unsupported.
In another place, I had to connect to the memcache ... The one, if there is no value, returns ... No, not nil, and not "userdata: nil", but "userdata: null". How to work with this? Now I have sketched a helper that checks the truth, and then checks for the similarity of string representations. What if another data source is added, which will return one more incomprehensible data type?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Lerg, 2015-12-29
@Lerg

In pure Lua, only nil, if you connect other services, then each needs to be specially processed. Helpers are indispensable. In this case, the problem is not the language, but the radish and memcache wrappers.

B
behran30, 2017-03-23
@behran30

ngx.null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question