voben
01/10/2020, 2:51 PMwhen expression to test some cases, why do I have to use the is keyword sometimes, and other times I don’t?Mike
01/10/2020, 2:53 PMis compares Types. It's an operator of sorts.voben
01/10/2020, 2:54 PMis keyword and other times it doesn’t, why is that the case?Dominaezzz
01/10/2020, 2:56 PMis won't be required is it's an object ?voben
01/10/2020, 2:56 PMVlad
01/10/2020, 2:57 PMis is basically an instanceOf check. Enums and objects are singletons so there is no need to perform an instanceOf comparisonvoben
01/10/2020, 2:59 PMDominaezzz
01/10/2020, 3:01 PMsealed class Example
data class Wrap(val value: Int): Example()
object None : Example()
val tmp: Example = TODO(...)
I think it's because you can do if (tmp == None) or if (tmp is None) but you can only do if (tmp is Wrap) . I'm sure you know why if (tmp == Wrap) doesn't work.arekolek
01/10/2020, 3:04 PMis when checking for `object`s anyway. This way when looks less cluttered and if later I decide to convert the object to a data class I don’t have to change the code in every when it occurredarekolek
01/10/2020, 3:06 PM