问题描述
布尔返回方法的命名约定是什么?
What is the naming convention for boolean returning methods?
在某些情况下,在方法前面使用是",有",应该",可以"听起来不错,但我不确定.有没有更好的方法来命名此类方法?例如:检查卡验证的功能.我应该称它为isValidCard
还是cardValidation
还是其他名称?(我在这里找不到它: https://kotlinlang.org/docs/reference /coding-conventions.html )
Using an 'is', 'has', 'should', 'can' in the front of method sound ok for some cases, but I'm not sure.Is there a better way to name such methods?for example: a function that checks card's validation. Should I call it isValidCard
or cardValidation
or another name?(I didn't find it here: https://kotlinlang.org/docs/reference/coding-conventions.html)
推荐答案
Kotlin命名风格假定您使用Java命名约定进行了可能的扩展.我建议您对有关Java的同一问题使用此答案.
Kotlin naming style assumes you use the Java naming conventions to the possible extend. I suggest you use this answer to the same question about Java.
更新:他们已经发布了编码约定 http://kotlinlang.org/docs/reference/coding-conventions.html
UPDATE: they have released coding conventionshttp://kotlinlang.org/docs/reference/coding-conventions.html
这篇关于布尔返回方法的Kotlin命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!