lua-users home
lua-l archive

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


On 24 April 2017 at 17:06, Bill Kelsoe <wildbillkelsoe@gmail.com> wrote:
> In Chapter 3 concerning relational operators expressions, PIL says that "if
> values have different types, Lua considers them not equal"

that means that any value is different of any value of a different
type.  p.ej any string is different to any number

> So if I understood this, this means that if a boolean and a string are
> related, using ~= , means that they are like apples and oranges?

yes.  (except that i don't see what you mean by "related", I guess the
word was "compared")


> Because right after that statement, "Otherwise, Lua compares them according
> to their types."

"Otherwise", means "if the previous sentence doesn't apply".  the
previous condition was "values have different types", so here the
condition is "both values have the same type".  then, the comparison
is according to that type.


> So if a value is Boolean meaning either true or false, and the other
> comparator is a String, of the value "true", so they are evaluated equal by
> Lua even if ~= is used?

no; a boolean true is of a different type of a string "true", so
they're different.



-- 
Javier