如果item在Lua数组中

时间:2015-05-09 17:12:58

标签: arrays lua lua-table

如何检查单词是否在数组中...例如:

fruits = { 'apple', 'banana' }
value = "carrot"
if not value == fruits then
  print ( value .. " is not a fruit" )
end

或类似的东西?我更喜欢纯粹的Lua。

1 个答案:

答案 0 :(得分:1)

直接的方式:

 g=e+f;   // will automatically construct a Derived from the result
          // and then execute `Derived`'s default `operator=` which 
          // will call `Base`'s `operator=`