Add Kotlin Coding Guideline
This commit is contained in:
27
doc/kotlin-coding-guideline.md
Normal file
27
doc/kotlin-coding-guideline.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
### `value.?let` or `if (value != null)`
|
||||||
|
|
||||||
|
Is really better to use
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
value?.let {
|
||||||
|
// some block
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
then
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
if (value != null) {
|
||||||
|
// some block
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
There is no return value so block is NOT expression.
|
||||||
|
|
||||||
|
### Don't use anonymous class implementation
|
||||||
|
```kotlin
|
||||||
|
val value = object : Type {
|
||||||
|
// implementation
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Reference in New Issue
Block a user