Advanced Kotlin

Kotlin Delegates

fun <T : Any> argument(): ReadWriteProperty<Fragment, T> 
= FragmentArgumentDelegate()

Default & Named parameters in functions

fun add(a : Int = 0, b : Int = 0) =  a + b

Inline functions to use higher-order functions effectively

public inline fun print(message: String) {
System.out.print(message)
}
fun normalFunction(){
print("Hello")
print("world")
}
fun normalFunction(){
System.out.print("Hello")
System.out.print("world")
}

The mighty when statement in Kotlin

Simple ‘when’ block

when(number) {
0 -> println("apple")
1, 2 -> println("banana")
3 -> println("grape")
4 -> println("Orange")
else -> println("Not a fruite")
}

Return values with ‘when’ block

Arbitrary conditions

Using ‘when’ without argument

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

WLSDM & WL-OPC WebLogic Monitoring Solutions: Customer Questions and Answers

MySQL 8.0.22 | Rules for the tables with Foreign Key

Setup IPSec Tunnel between Microsoft Azure and Alibaba Cloud with VPN Gateway

Releasing Fantom Vision

The importance of DSA

How to Install and Configure LXC Container on Ubuntu 16.04

7 Disaster Recovery Planning Mistakes That Can Render Your Business Continuity Plans Ineffective

Forget AWS Lambda, so long Kubernetes — this is the future of serverless

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
Kiran Choudhary

Kiran Choudhary

More from Medium

Why not to use Volley in 2022?

fragment stuck cannot move to another fragment in Android Navigation

Building a Simple calculator App in android studio.

Kotlin scope functions: let, run, with, also, apply