How to check if two tables(objects) have the same value in Lua

后端 未结 6 1570
粉色の甜心
粉色の甜心 2021-01-04 02:00

I wanna check if two tables have the same value in Lua, but didn\'t find the way.

I use the operator ==, it seems just to check the same objects, but no

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 02:41

    There is no built-in function for comparing tables by contents.

    You'll have to write your own. You'll need to decide whether you want to compare tables by contents shallowly or deeply. See https://web.archive.org/web/20131225070434/http://snippets.luacode.org/snippets/Deep_Comparison_of_Two_Values_3 for some ideas.

提交回复
热议问题