Skip to content

CriPstian/how-to-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How To Kotlin

Points to cover

lateinit and delegated properties

Property delegates don’t have to implement any interface, but they have to provide a getValue() function (and setValue()

val lazyGuy: LazyGuy by lazy { LazyGuy("is always late") }
  • TODO

Helpful functions right out of the box.

fun toBeImplemented() {
    TODO("Your reason")
}

Written as expression body

fun toBeImplemented() = TODO("Your reason")
  • Named and default arguments
  • Classes are final by default
class Pet(val name: String)

class Dog(name: String):Pet(name) // WON'T WORK: Pet is default final

We need to specify the open keyword

open class Pet(val name: String)
  • inlined if-else
fun testThis(str: String) = if(str.lenght > 2) "Test1" else "Test2"
  • inline try-catch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages