Page 1 of 1

Check if a variable is in an array

PostPosted: Mon Jul 10, 2017 11:00 pm
by HQTG1
Is there a built-in function that simply checks if a value is in an array and returns a boolean? I've looked at all of the Thyme tutorials I could find and I've checked the massive list of Thyme commands & variables sticky. All I want to do is this:
Code: Select all
array0 = [1, 2, 3]

var0 = 1

    <check if var0 is in array0> ? {
        doAThingIfVar0IsInArray0()
    } : {
        DoAThingIfVar0IsNotInArray0()
    }


Looking at the lack of support for everything else (we don't even have loop structures), I won't be surprised if there isn't an easy way of doing this.

Re: Check if a variable is in an array

PostPosted: Wed Aug 30, 2017 7:57 am
by Luezma
If you want to check if an element of array0 is equal to var0 and you know how many elements does array0 has (0 being the first element), then:
Code: Select all
for(array0lenght, (i)=>{
    array0(i) == var0 ? {doSomeStuff()} : {dance()}
})