2022-08-15
2126
#kotlin
Rahul Chhodde
127135
Aug 15, 2022 â‹… 7 min read

Initializing lazy and lateinit variables in Kotlin

Rahul Chhodde I'm a software developer with over seven years of experience in different web technologies.

Recent posts:

float ui tutorial

Building responsive websites fast: A Float UI tutorial

Discover Float UI, a set of pre-made templates that leverage the power of Tailwind CSS to help developers create professional websites quickly.

Murat YĂĽksel
Apr 21, 2025 â‹… 22 min read
react toastify

React-Toastify (2025 update): Setup, styling & real-world use cases

Learn how to use React-Toastify in 2025, from setup to styling and advanced use cases like API notifications, async toasts, and React-Toastify 11 updates.

Chimezie Innocent
Apr 18, 2025 â‹… 18 min read
5 Best Open Source Tools For Cross-Browser CSS Testing

5 best open source tools for cross-browser CSS testing

Discover open source tools for cross-browser CSS testing like Playwright and BrowserStack to catch rendering errors, inconsistent styling, and more.

Peter Aideloje
Apr 18, 2025 â‹… 11 min read
react suspense data fetching

How to handle data fetching with React Suspense

With the introduction of React Suspense, handling asynchronous operations like data fetching has become more efficient and declarative.

Ovie Okeh
Apr 18, 2025 â‹… 10 min read
View all posts

One Reply to "Initializing <code>lazy</code> and <code>lateinit</code> variables in Kotlin"

  1. The `pi` example here is a bit misguided, because using `lazy` for that will consume more memory than just initialising the constant value.

    The one case where I would consider making `pi` lazy is if you are writing an arbitrary precision arithmetic library and have to calculate the value, because calculating the value can be very expensive if the caller asks for a large number of digits.

Leave a Reply