判断是否是正在运动的状态, 这个函数的函数名你们一般都怎么起?

2020-02-14 09:28:01 +08:00
 smallpython
我的话就是 def check_is_moving_status():pass

是不是不太好?
4018 次点击
所在节点    程序员
31 条回复
optional
2020-02-14 13:39:23 +08:00
@Mohanson 如果跳着移动。。。
j140z1
2020-02-14 13:58:10 +08:00
isMoving or isInMotion
alya
2020-02-14 14:04:33 +08:00
is_run()
crella
2020-02-14 14:08:13 +08:00
def status_moving?

end
visitant
2020-02-14 14:31:57 +08:00
@laoyur 返回 bool 变量最好不要用 is 开头吧,做一些复杂逻辑判断时理解成本会很高
hxtheone
2020-02-14 14:38:47 +08:00
@GavinFlying #2 换到别的语言特别怀念 ruby 函数名里可以用 ? 和 !
w1573007
2020-02-14 15:14:22 +08:00
def shifozhengzaiyundong
LancerEvo
2020-02-14 16:17:40 +08:00
正解是 is moving

命名含 if 的没有考虑调用的地方: if checkIfMoving... 不冗余?

命名含 check 的已经冗余了 if checkIsMoving... 这个 check 完全没必要

这点道理想不明白的我是不会招来当队友的
lastisee
2020-02-14 16:42:03 +08:00
@GavinFlying 加一
hanhuoer
2020-02-14 18:50:50 +08:00
function isMoving() {...}
arjen
2020-02-15 00:23:57 +08:00
boolean isMoving();

所有返回类型是布尔值的我都用 is 开头

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/644451

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX