Photo by Joel Filipe on Unsplash

Data Classes

data class Person(val name:String, val age:Int)

Delegates

class FavoriteModule(dispatcher:Dispatcher):Dispatcher by dispatcher
class FavoriteModule(
dispatcher:Dispatcher
):BaseModule, Dispatcher by dispatcher

Type aliases

when(value) {
is Int -> if(value in 2..5) pass()
is Char -> if(value in 'a'..'d') pass()
)
typealias NumericalGrade = Int
typealias AlphabeticalGrade = Char
when(value) {
is NumericalGrade -> if(value in 2..5) pass()
is AlphabeticalGrade -> if(value in 'a'..'d') pass()
)
typealias NumericalGrade = Int
typealias AlphabeticalGrade = Char
when(value) {
is NumericalGrade -> if(value in 2..5) pass()
is AlphabeticalGrade -> if(value in 'a'..'d') pass()
"G", "VG", "MVG" -> pass()
)
when(grade) {
in 2..5 -> pass()
in 'a'..'d' -> pass()
"G", "VG", "MVG" -> pass()
)
typealias Degree = Double
typealias Radian = Double
fun Degree.toRadian(): Radian = this / 180 x Math.PI
fun Radian.toDegree(): Degree = this × 180° / Math.PI
fun getSectorArea(centralAngle: Radian, radius: Double): Number {
return (centralAngle.toDegree()/360) * Math.PI * radius.pow(2)
}
// When being more descriptive in calls that can be misinterpreted.
typealias
Degree = Double
typealias Radian = Double
fun convert(angle: Degree): Radian
// When handling function types like lambdas
typealias Lambda<T> = () -> T
fun doOnComplete(action: Lambda<Int>)

Lead Developer at Qvik, Coach, Agile Thinker, GDG Lead.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store