代码改变世界

if-return 语句

2018-07-03 16:06  xplorerthik  阅读(328)  评论(0编辑  收藏  举报
if(A > B):
    return A+1
return A-1

or

if(A > B):
    return A+1
else:
    return A-1

++++++++++++++++++++++++++++++++++++++++++


1# Bad
if (foo)
  return 1
else
  return 2

2# Good
if (foo)
  return 1
return 2

3# Good
return 1 if foo else 2