Yes, for sure, as long as you're interested in the result of the expression. But I've seen people do stuff like this, which is what I'm advocating againts:
Yes you right. But what are you think about react reducer switch like this? :
constsomeReducer(state,{type,payload}){switch(type){caseSET_SOME:return{...state,some:payload}caseWORK_WITH_OTHER:return{...state,other:payload,some:false}// ... and so ondefault:returnstate;}}
Yes, for sure, as long as you're interested in the result of the expression. But I've seen people do stuff like this, which is what I'm advocating againts:
Yes you right. But what are you think about react reducer switch like this? :
Looks like a regular reducer to me... how is this related to what we were talking?
reducer is looks same as ternary with two function, just case use one condition with many pure function.
Again, this is because you care about the result of the function. My take is: use statements for side effects and expressions for pure functions.