We could use IF, ELSE IF, ELSE statements… Many times in code you may want to do many different things based on different string values
For example, I might have three different landing pages based on 3 conditions, and upon button press I might want to say
IF “has-users”==0 goto empty landing
ELSE IF “has-users”==1 goto landing a
ELSE IF “has-users”==2 goto landing b
ELSE goto other
I did find that you can string a bunch of IF statements together and leave the ELSE blank, but that feels a bit hacky to me ;). It does work though, if others are looking for this capability.
I’m too lazy to test - if you string a load of IFs together, do they all get evaluated equally?
Not sure if I am following you, but for my purposes I am checking for a string value of 0, 1, or greater than 1 and it’s doing what I want and going to the correct location based on that value. I haven’t attempted to see what happens if two or more items evaluate to true at the same time though.
I think I mean that if you have multiple IFs, does it stop evaluating at the first TRUE? Not sure what to expect.
It would be great to have more “else if’s” and “while” conditionals. It can get a bit unwieldy.
For example, I worked on a swipe+loader that would show/hide elements if a variable was a certain number (this makes it look like it is spinning), I had to use a few if statements.
I’d love to be able to copy and paste conditionals/variables, so I wouldn’t have to retype everything if I am reusing a similar statement.
We definitely need this. Not just is a bunch of if’s with blank else’s a bit tiresome hacky to do, but it is also a problem, that you can stop the following statements from being evaluated, so you have to add additional conditionals to your if’s to prevent it.
Yup- definitely need this.
Thank you! I was looking for any workaround for missing elseif and haven’t found anything until you pointed out this is possible.