DEV Community

Cover image for lateinit vs nullable type | KnowYourKotlin
Chetan garg
Chetan garg

Posted on • Edited on • Originally published at chetangupta.net

1

lateinit vs nullable type | KnowYourKotlin

Hi #androidDevs, This is Androidbites where I try to break down a small concept into an understandable code snippet and share my learning experience with it.

Today's topic is related to handling nullability using lateinit modifier, I absolutely agree null is the Billion dollar problem in a programming language, and for you, as a developer, it's your responsibility that your app doesn't fall in as a victim of it and not crash your app due to that, In kotlin there are many languages functionalists build in that enable you to aware of null happening code and ask you to cater them properly.

Lateinit is one of those tools, the solution of a problem is not to create that problem right? Similarly instead of having a nullable type just replace it with non-null type? right 🧐? an obvious solution, 

let's dig deeper with the snippet below, 👁 on the code 💻.

Alt Text

if you like to know more on the same topic read the complete article on

👉 AndroidBites|lateinit-vs-null

Hope to see you on the other side...

Until next time. Happy Hacking! 👩‍💻

Stalk Me 👀 :
LinkedIn | Medium | Twitter | StackOverflow | CodeWars |WorkX |Github |Instagram |Youtube

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay