Numeric representation

All numeric values are represented as primitive values in the JVM unless it is a nullable value. For example, if Long? or generics are involved. Kotlin has a ternary equals operator (===) that can be used to check identity. Consider the following code example:

var a : Long = 10L; 
println(a === a)

The following code will print true:

var a : Long = 10L; 
var b : Long? = a;
var c : Long? = a;
println(b === c)

However, it will print false if the b and c variables are nullable, will not use primitive data types, and thus will have different identities for each of those respectively. Yet println(b == c) will print true as it will be checking equality, not the identity.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.221.67