Having a class Config
with nullable boolean sAllowed
and a interface function returns a nullable Config
interface IConfig {
fun getConfig() : Config?
}
class Config (var sAllowed: Boolean?=null)
and when want to use this boolean:
var sAllowed = false
// some loop ...
val config = iConfig.getConfig()
if (config != null) {
sAllowed = sAllowed || config.sAllowed == true
}
but the config.sAllowed == true
translates to:
Intrinsics.areEqual(config.getsAllowed(), true);
and the Intrinsics.areEqual(config.getsAllowed(), true);
is:
public static boolean areEqual(Object first, Object second) {
return first == null ? second == null : first.equals(second);
}
the first.equals(second);
is :
public boolean equals(Object obj) {
return (this == obj);
}
the doc for equals(Object obj)
is Indicates whether some other object is "equal to" this one
, not the value equality.
Is it sounds like the config.sAllowed == true
is checking object equality not value, or what am I missing here?
* The {@code equals} method for class {@code Object} implements
* the most discriminating possible equivalence relation on objects;
* that is, for any non-null reference values {@code x} and
* {@code y}, this method returns {@code true} if and only
* if {@code x} and {@code y} refer to the same object
* ({@code x == y} has the value {@code true}).
* <p>```