Dictionary with delegate or switch?

后端 未结 6 1424
一生所求
一生所求 2021-02-07 01:21

I am writing a parser which calls some functions dependent on some value.

I can implement this logic with simple switch like this:

switch(some_val)            


        
6条回答
  •  情话喂你
    2021-02-07 01:47

    Both do the same (well you should check if the key appears in the dictonary).

    It is just a matter of readability. What looks the best for your and more important, what do people reading your code would prefer.

    (I think the dictionary)

提交回复
热议问题