- 开发环境:IntelliJ IEDA
- 个人博客:http://blog.csdn.net/IInmy
- 项目源码:https://github.com/Rushro2m/KotlinForOfficial
- 官方文档中文版:https://www.kotlincn.net/docs/reference/coding-conventions.html
1、命名风格
Kotlin一般默认使用Java的编码规范
- 使用驼峰式命名(避免命名含有下划线)
- 类型名以大写字母开头
- 方法和属性以小写字母开头
- 使用4个空格缩进
- 共有函数应撰写函数文档,这样这些文档才会出现在Kotlin Doc中
//驼峰命名
val lastName = "张三"
//类名或接口,大写开头
interface Foo<out T : Any> : Bar {
//...
}
interface Bar {
//...
}
//方法名小字母开头,遵