英文:
Checkstyle saying "Conditional logic can be removed"?
问题
这是 Checkstyle 不喜欢的部分,具体来说是 "if (eggs >= 3)" 这一行。我该如何更改以使其通过 Checkstyle?
if (flour >= 1)
{
if (sugar >= 2)
{
if (eggs >= 3)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
英文:
This is the part that checkstyle doesn't like, specifically the "if (eggs >= 3)" line. How can I change this to make it pass for checkstyle?
if (flour >= 1)
{
if (sugar >= 2)
{
if (eggs >= 3)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
答案1
得分: 1
public static boolean foo(int flour, int sugar, int eggs) {
return flour >= 1 && sugar >= 2 && eggs >= 3;
}
英文:
public static boolean foo(int flour, int sugar, int eggs) {
return flour >=1 && sugar >= 2 && eggs >=3;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论