Intro to Kotlin

Note that this is a showcase of Kotlin's powerful features over Java that you might
not encounter on first use. For full
details, I strongly recommend devs read the entire reference linked above. It's worth it.

Extension Functions

In Java, we often require new methods for existing classes. Rather than
extending the class, we may create static methods that take in the object reference and modify it
accordingly.

Test test; //assume implementation
static void update(Test test);

The call involves placing the method before the reference, which may be harder to read when chained

show(update(clear(init(test))));

Kotlin on the other hand, allows for extension functions. Given a type, it can add a method onto it,
as if it were in the original class. The implementation is done statically, but it produces a very
elegant outcome:

Objects

Want a singleton? Use an object. It's that simple. Kotlin by default does not have static
implementations, though they may be added through the @JvmStatic annotation.
The benefits of singletons are clear, as they adhere to object oriented practices and are actually
extensible.

Getters and Setters

Unlike Java, Kotlin upholds property style syntax. There is no need to create your own getters and
setters, as they are done for you.
By default, they do nothing more than retrieve the field, or save the new value into the field.
You may override it by doing the following:

val opposite: Boolean //returns the opposite of what is saved
//field is the name of the stored value (backing field)
//get is not overridden
set(value) {
field = !value
}

Delegates

Delegation is a very powerful structure that allows us to allow other classes to handle our methods
or variables.
This allows for lazy patterns (where an execution is only done upon first get), and allowing some
basic form of multiple extensions, by delegating interface methods to fully implemented classes.