Check if a variable is in an array
2 posts • Page 1 of 1
Check if a variable is in an array
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:
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.
- 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.
-
HQTG1 - Posts: 2
- Joined: Thu Nov 03, 2016 5:12 am
Re: Check if a variable is in an array
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()}
})
- Luezma
- Posts: 14
- Joined: Thu Dec 13, 2012 7:19 pm
- Location: Argentina
2 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 13 guests