Extension Functions in Kotlin

fun <class_name>.<extention_function>()
fun Int.isEven(): Boolean {
return when (this % 2) {
0 -> true
else -> false
}
}

val number = 8
println("${number.isEven()}")

19 Years Old | Pursing Android Development

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

Recommended from Medium

MY JOURNEY WITH DLITHE BOOTCAMP-JAVA FULLSTACK DEVELOPMENT|Week 5(Apr18-Apr24)

First impressions of Drupal8

Task:- Store your data in AWS EFS and attach EFS with multiple EC2 instances

Managing windows with vim

Comparing Two Most popular Rust frameworks (Actix-web and Rocket)

GNOME 42 — The Nonsense Continues

Continuous update delivery to WSO2 products with Ansible

How to Build Serverless Apps with AWS Lambda

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
Alexander Portillo

Alexander Portillo

19 Years Old | Pursing Android Development

More from Medium

Hello, Kotlin!

LiveData in Kotlin

How and When to convert a Utility function in Kotlin to an Extension Function

Android Protobuf with kotlin and Wire