问题
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
回答1:
The Kotlin documentation refers to it as the not-null assertion operator
.
Personally, I call it the hold my beer operator
.
回答2:
"Kotlin in Action" calls it the not-null assertion operator. We've decided to update the docs to use this term too.
回答3:
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.
回答4:
I use to call it "double bang", but actually hold my beer operator
does get to the heart of it too (thx @Todd ;-)).
回答5:
I'm using "force-unwrapping" (same as is in Swift).
来源:https://stackoverflow.com/questions/47543386/what-is-the-name-of-kotlins-operator