Else if

hey guys,
i m triyng to figure out how to use “else if” in code block, when my input is not in list everything is ok, but when my inpul will be in list it gives me null. Why?

So much thanks for any help

@martin.biras You could do this easily without Imperative code
something1

imp <= 10 ? "something <= 10" :
imp <= 20 ? "something <= 20" :
"something > 20";

However, if you want to practice with Imperative code, you’ll need to loop through each item in your list to make it work

imp;
a = [];
j = 0;
[Imperative]
{
	for (i in imp)
	{
		if (i <= 10)
		{
			a[j] = "something <= 10";
			j = j + 1;
		}

		elseif (i <= 20)
		{
			a[j] = "something <= 20";
			j = j + 1;
		}

		else
		{
			a[j] = "something > 20";
			j = j + 1;
		}
	}
	return a;
};
11 Likes

So much thanks Vikram_Subbaiah, that s exactly what i was looking for

1 Like