switch / case:case 评估为 true,不执行
我正在努力处理 switch case 语句,该语句被评估为 true。 然而,该 case 语句的代码并未被执行。 这对我来说很奇怪。任何帮助将不胜感激。提前致谢。
switch ([operation, state]) {
case [(Array((Number(state.result).toString() === [''])))
&& (Array((Number(state.secondNumber).toString() === ['']))) &&
state.mathOp === '' && operation === '-'] :
console.log([operation, state]);
setState((state) => ({
result: -Math.abs(Number(['-'])),
mathOp: operation,
secondNumber: [""],
}));
setUpdatedState(false);
setValue(0);
break;
default:
console.log(new Error('Unknown clickHandlerOp function error...'));
}
I'm struggling with a switch case statement, which is evaluated as true.
Nevertheless, the code for that case statement is not being executed.
It's weird for me. Any help will be appreciated. Thanks in advance.
switch ([operation, state]) {
case [(Array((Number(state.result).toString() === [''])))
&& (Array((Number(state.secondNumber).toString() === ['']))) &&
state.mathOp === '' && operation === '-'] :
console.log([operation, state]);
setState((state) => ({
result: -Math.abs(Number(['-'])),
mathOp: operation,
secondNumber: [""],
}));
setUpdatedState(false);
setValue(0);
break;
default:
console.log(new Error('Unknown clickHandlerOp function error...'));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论