These are chat archives for JetBrains/kotlin

20th
Aug 2017
Sharikov Vladislav
@sharikovvladislav
Aug 20 2017 11:42
hi
is there any channel for idea/webstorm ? :)
Ravi Teja
@tekjar
Aug 20 2017 15:32
Hi. What is the difference between '?' and '!'
?
I'm using some java libraries in kotlin and the type is this --> PCollection<JsonArray!>!
Ange Bagui
@angebagui
Aug 20 2017 15:34
@tekjar with ? the compiler check if the object is non-null value before perform action
with !! the compiler can throw Null Pointer exception if the object is null
Ravi Teja
@tekjar
Aug 20 2017 15:36
Ohh..I thouht '!!' was that
Ange Bagui
@angebagui
Aug 20 2017 15:36
yes !!
with !! the compiler can throw Null Pointer exception if the object is null
Ravi Teja
@tekjar
Aug 20 2017 15:38
Ok. I should reframe my quesion. What is the diff between ! and !!
PCollection<JsonArray!>!
That was the type of return object when I call a java method
Ange Bagui
@angebagui
Aug 20 2017 15:39
it means that it's nullable object that come from java api
Ravi Teja
@tekjar
Aug 20 2017 15:39
I was expecting it to be
PCollection<JsonArray?>?
Got it. I'm a kotlin newbie..But why isn't it being coverted to PCollection<JsonArray?>? instead? This makes sure that user checks null references right?
Ange Bagui
@angebagui
Aug 20 2017 15:50
PCollection<JsonArray?>? is nullable object that come from kotlin api
PCollection<JsonArray!>!
just mean that object came from Java. So the IDE doesn't know if it's Kotlin Nullable or NonNull
Ravi Teja
@tekjar
Aug 20 2017 15:59
@angebagui Got it thanks. You cleared by doubt. But my new doubt is w.r.t kotlin desing. Shouldn't kotlin automatically convert '!' object to '?' object to make sure that the language is null safe?
It the current case, obj.someMethod() will result in null pointer exception if the the object is null
right?
design*
Ange Bagui
@angebagui
Aug 20 2017 16:10
in java we can add Nullability annotations
the kotlin compiler will ...
Ange Bagui
@angebagui
Aug 20 2017 16:19
Ravi Teja
@tekjar
Aug 20 2017 16:28
@angebagui Thanks :)