Idioms and Anti-Patterns

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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.122.127