Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Build an if statement
Started by andavidosp Oct 09 2018 02:30 PM

- - - - -
1 reply to this topic
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 25 posts
  • Corona SDK

Is there any way in which I can build an if statement like this: 

if (string.find( fase, "League" ) or  string.find( fase, "Cup" ) then

from an array where i have this:


tournament =
{nombre = "league"},
{nombre = "cup"}
without the need to go through the array with a for, I was thinking about if it could be done with concatenating or something like that

[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Corona Geek

  • 1,244 posts
  • Corona SDK

What does "fase" mean?


I have a helper function that loops through a table and returns true or false if it finds the value. Then I can do an if statement similar to the one you stated.


But you don't want to use a loop so the only thing I can think of is to encode it as a json string:

local string = json.encode(<table>)

Then you can use the Lua string functions to see if the value is in the string. But why store it in a table if you are going to string it out to search, just create a string and append whatever values you want and then use the string functions to see if the value exists.