逻辑编程帮助
A = if infos !empty and inputs 为空 - 删除;
B = 如果信息为空并且输入为空 - 执行添加;
C = if infos !empty and inputs !等于 infos - do add;
我们可以这样说:
if B //it's the most common operation, so at the beginning.
{
//add
}
else
{
//remove
}
elseif(c)
{
//the same add
}
我相信这可以是更好的思考。我可以得到你的帮助吗?
提前致谢,
A = if infos !empty and inputs empty
- do remove;
B = if infos empty and inputs !empty
- do add;
C = if infos !empty and inputs !equal to infos
- do add;
We can have like:
if B //it's the most common operation, so at the beginning.
{
//add
}
else
{
//remove
}
elseif(c)
{
//the same add
}
I believe this can be better thinking. Can I have your help?
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
请记住,最外面的条件检查两个值永远不会为空(实际上永远不会相同)。例如,
如果输入为空infos< /strong> 不能为空。因此,删除。
不同且输入不为空=> info 是否为空并不重要=>添加。
Remember, the outermost condition checks that both values are never empty (never the same, actually). E.g.,
If inputs is empty infos can not be empty. Therefore, remove.
Different and inputs not empty => it doesn't mather whether info is empty => add.
它是
if
、elseif
(elseif
只要你想要),最后是else
:it's
if
,elseif
(as muchelseif
's as you want) and finallyelse
:你一定能做到。只需订购条件块:
If...Else If...Else
。You sure can do that. Just order the conditional blocks:
If... Else If... Else
.我认为简短而清晰。
Short and clear in my opinion.
您可以使用 OR 运算符组合 B 和 C 的条件:
You can combine the conditions of B and C with the OR operator: