whenexpressions for cases, avoid other usage of
when statement, which is not exhausted.
if ... else if ....
when for both
cond, which is confusing.
Thus avoid use
when expression for
vararg p: T underhood
but special array types for basic types, e.g.
vararg p: Int.
p: Array<T> and
vararg p: T behaves differently.
In other words, given a function
Array<T> -> Unit,
we do not know how to invoke it just from its signature.
Array<T> -> Unit may be an infix function,
but all infix functions can be invoked as normal functions.
invoke method for objects,
every time I see
I am sure it will return an instance of
If we use lower case for object name,
then once we see
we may think it is a function.
But we can pass neither
::lowerCase to a higher-order function.
return in lambda returns the outer function.
This is confusing.
Kotlin supports top level functions, often cleaner than component objects.
They are not first-class:
foo:baris not supported.
val f = fun()... except for:
inlinefor reified generics
Overloading an operator should be consistent to all types supporting the operator.
Infix functions provides a new syntax of function call, similar to operators.
Only use infix functions when they are obviously cleaner than non infix form.