Sign in Go Pro

Kotlin

Delegation by Using the lateinit Modifier

 

Up next

Previous

About

In Kotlin we need to initialize a variable or mark it as null which is not mostly convenient because then we need to add null checks every time we use the variable.

That's where lateinit modifier comes in, it gives guarantee to the compiler that the variable will be initialized at the later stage and tells compiler to relax on Null Safety.

In this lesson you will learn:

  • How to use lateinit modifier
  • Verify the behavior of lateinit
  • Check what happens if lateinit variable is not initialized at later stage

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Kotlin