avoiding if statements

前端 未结 24 749
心在旅途
心在旅途 2021-01-30 08:39

I was thinking about object oriented design today, and I was wondering if you should avoid if statements. My thought is that in any case where you require an if statement you ca

24条回答
  •  日久生厌
    2021-01-30 09:43

    Explain how to implement the following without an if statement or ternary logic:

    if ( x < 5 ) {
       x = 0
    } else {
       print x;
    }
    

提交回复
热议问题