What is a more elegant solution to these nested if/elseif statements?

后端 未结 9 1880
野趣味
野趣味 2021-01-12 17:09

I\'m building a website that contains users with user profiles. Many of the fields in the profile are optional.

There is an opportunity for a lot of user-generate

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 17:49

    A State machine works very nicely for involved logic like that. It's very simple to implement as well (using a switch statement).

提交回复
热议问题