Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name of Kotlin's !! operator

When in a conversation with other developers, what do I call the !! operator?

In Kotlin, the ?: is called the Elvis operator

These sources don't say what the name of !! is:

  • http://kotlinlang.org/docs/reference/null-safety.html#the--operator
  • http://kotlinlang.org/docs/reference/keyword-reference.html

Looking online, the generic term for !! is double bang. Do I use the same for Kotlin even though swift's ! operator is called forced unwrapping (Note: the ! in swift is similar to Kotlin's !!.)

What I'm specifically looking for:

  • A name that I can verbally call the !! operation that Kotlin developers can understand
  • A name other than double exclamation or bang bang or double bang
like image 649
Jon Avatar asked Nov 29 '17 00:11

Jon


2 Answers

The Kotlin documentation refers to it as the not-null assertion operator.

Personally, I call it the hold my beer operator.

like image 118
Todd Avatar answered Nov 04 '22 17:11

Todd


I like to say "non-null asserted call" for things like

a!!.length

that is also how it is shown in the Android studio ALT+ENTER context menu.

Makes sense to me because that sums up what it is actually doing.

like image 30
donfuxx Avatar answered Nov 04 '22 18:11

donfuxx