Idioms


Idioms

The data holds classes found in Kotlin's data classes. Such classes are marked as data.

  • Getters and Setters for all properties (getters only for vals)
  • equals()
  • hashcode()
  • toString()
  • copy()
  • componentN() (where N is the corresponding property in order of declaration)

Serializable and serialVersionUid

To create serialVersionUid for a class in Kotlin, this covers a member on the Class’s Companion object. The most suited bytecode comes with a private ConstVal, which will become a private static variable on the containing class.

Using apply to initialize objects or to achieve method chaining

This value is called the receiver and returns this value to the release of the specified function block. Although the Kdoc is not so helpful, it is a useful activity. It enables to avoid some code calling more than one object in the back.