What is the Kotlin double-bang (!!) operator?

mbr_at_ml picture mbr_at_ml · Dec 17, 2015 · Viewed 70.1k times · Source

I'm converting Java to Kotlin with Android Studio. I get double bang after the instance variable. What is the double bang and more importantly where is this documented?

mMap!!.addMarker(MarkerOptions().position(london).title("Marker in London"))

Answer

hotkey picture hotkey · Dec 17, 2015

This is unsafe nullable type (T?) conversion to a non-nullable type (T), !! will throw NullPointerException if the value is null.

It is documented here along with Kotlin means of null-safety.