Alternative to multiple nested conditional if-then?

I often find myself in a situation when I need to use multiple nested if-then conditions based on some value in the incoming data. Is there any other way to 'branch' out the flow of the functions?

E.g. I have some 'segment id' for all the entries coming into the system and I need the endpoint to apply different functions based on that segment id. To do it right now I need to nest a lot of conditional if-then nested under each other, for every segment id value. Anything else I can do to perform such 'branching'?

Thanks
Other
7 replies