Easy way to see if something is in an array through value instead of index?
When using a dictionary you can check if something is in it very easily like so:
6 | if dict [ "whatever" ] then |
As you can see it can be done very easily by seeing if the given dictionary contains that key, however with a typical array you cannot do that, you must do it by index.
01 | local array = { "yeh" , "ok" } |
13 | for _, v in pairs (array) do |
This is not that big of a problem as I can easily make a function like this
1 | local function findIn(value, array) |
2 | for _, v in pairs (array) do |
3 | if v = = value then return true end |
I would simply like to know if there is a simpler way to do this.