I am a Kotlin newbie , i am slightly confused with nullable types, my main confusion is in understanding the infix to function. The to function is defined as :
public infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
As i understand , a nullable type is declared as “T?” and as per the above definition A is not a nullable type.
But in the IDE, when i write a statement like : val test = null to “NULL”
it compiles and produces a Pair<Nothing?,String>
Why does it produce “Nothing?” why not any other nullable type Like “Unit?” or “Any?”
Secondly if i were to write my own infix “to” which would prohibit nulls how would i declare that ?
I am enjoying kotlin by the way, sorry if this question has been answered before.