This chapter discusses the best and worst practices in Kotlin. You'll learn what idiomatic Kotlin code should look like and which patterns to avoid.
After completing this chapter, you should be able to write more readable and maintainable Kotlin code, as well as avoid some common pitfalls.
In this chapter, we will cover the following topics:
- Let
- Apply
- Also
- Run
- With
- Instance checks
- Try-with-resources
- Inline functions
- Reified
- Constants
- Constructor overload
- Dealing with nulls
- Explicit async
- Validation
- Sealed, not enumerated
- More companions
- Scala function