Alternative to the “switch” Statement

后端 未结 8 2061
眼角桃花
眼角桃花 2020-12-04 20:15

I do not want to use Switch in my code, so I\'m looking for some alternative

Example with Switch:

function write(what) {

  switch(w         


        
8条回答
  •  抹茶落季
    2020-12-04 20:45

    Question 2:

    Generally, if you can replace custom control structures with a dictionary lookup, you're perfectly fine. It's easy to read and highly elegant -- stick with it.

提交回复
热议问题