Pitfalls in Kotlin

Null Security

Lateinit

In fact, by signing lateinit, we tell the compiler that we will take care of this later (and we will not write unnecessary checks for null here). Here we give the code that shows how IDEA highlights the syntax.

“!!” Operator

NullPointerException

Be careful with extension functions

Create a MutableMap, initialize it via ConcurrentHashMap, and call getOrPut
Let’s see what’s under the hood…
We register ConcurrentHashMap explicitly.
Under the hood…
Two ways to check for the presence of 3 and 8 in a HashSet
toString() for a null object yields the string “null” of 4 characters

Look for StringBuilder even where it is not supposed to be

What’s under the hood…

Check twice after the Kotlin version update

This is how we restrict logging.
private companion object: KLogging ()
What it looks like after updating the language version.

--

--

--

We are building IT-solutions for the Adtech and Fintech industries. Our clients are SMBs across the Globe (including USA, EU, Australia).

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

Recommended from Medium

Pop!_OS Switch Workspaces with Super + Number

What is linux and Learn basic commands

Utilising Object-Oriented Programming in Ruby to make our lives easier

Top 5 technologies in demand

(3.1) EasyBake Update

PCMan’s FTP Server v2.0.0 USER Buffer Overflow Exploit

Persistence in Android.

Design Portfolio from Scratch

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
Maxilect

Maxilect

We are building IT-solutions for the Adtech and Fintech industries. Our clients are SMBs across the Globe (including USA, EU, Australia).

More from Medium

Pitch for Kotlin

Writing Automated Tests in Kotlin

Ktor — Kotlin for backend development

Idiomatic WeakReference implementation by delegate in Kotlin