If Statement Problem - Always output first option

I wrote code block of " if…elseif…else" for testing a list and output different string, but the output is always the first item, please help?

@yatcheung ,

maybe this is a workaround with operators

KR

Andreas

2 Likes

Hi @yatcheung, welcome!
Since you are using key:value pairs to check if a string contains a certain sub-string and return a result then a dictionary is probably the way to go

def check_pipe(str, dict)
{
    return = [Imperative]
    {
        for (k in dict.Keys)
        {
            if (String.Contains(str, k))
            {
                return = dict[k];
            }
        }
        return = null;
    }
};
1 Like

Recived with thanks, I am working with your suggestion and the problem solved.

Your are very helpful for this issue, thanks a lot!