Kotlin Basics

The Unit return type declaration is optional for functions. The following codes are equivalent. Single-Expression functions:When a function returns a single expression, the curly braces can be omitted and the body is specified after = symbol

Explicitly declaring the return type is optional when this can be inferred by the compiler

String interpolation: […]

Continue reading

In public classes, use accessor methods, not public-fields

Occasionally, you may be tempted to write degenerate classes that server no purpose other than to group instance fields:

Because the data fields of such classes are accessed directly, these classes do not offer the benefits of encapsulation. You can’t change the representation without change the API. If a class is accessible outside its […]

Continue reading