lua-users home
lua-l archive

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


Sean Farrow wrote:
[...]
> if a string is empty, i.e "" can I compare it with nil?

If you like, but the result will always be false (because an empty
string *isn't* nil).

You can compare for equality (or inequality) any two values, regardless
of type.

You can only do an ordered compare (<, <=, etc) on two values of the
same type, subject to metatable tricks: that's pretty much only numbers
or strings, for example. (But not numbers *and* strings; "3" < 3 will
produce a type error).

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "A line dancer near a graduated cylinder, the blithe spirit inside
│ some wheelbarrow, and a tomato are what made America great!" ---
│ received via spam

Attachment: signature.asc
Description: OpenPGP digital signature