Hullaballoonatic
12/03/2019, 9:23 PMByte is a Number, then why isn't a Bit /`Boolean`?
Iirc, Boolean isn't actually stored with just one bit in memory, but does that actually matter?Hullaballoonatic
12/03/2019, 9:30 PMBoolean logically equivalent to a Bit , which is a numberstreetsofboston
12/03/2019, 9:35 PMChar is not a NumberHullaballoonatic
12/03/2019, 9:36 PMChar::toInt?Hullaballoonatic
12/03/2019, 9:37 PMByte is a number, the same can be applied to a BitHullaballoonatic
12/03/2019, 9:37 PMBit does exist in Kotlin. it's just called BooleanHullaballoonatic
12/03/2019, 9:39 PMHullaballoonatic
12/03/2019, 9:41 PMHullaballoonatic
12/03/2019, 9:42 PMHullaballoonatic
12/03/2019, 9:44 PMHullaballoonatic
12/03/2019, 9:48 PM&& differently from the bitwise and/& ? Shouldn't true xor false compile? It doesn't because true and false are not bitwise values, but in boolean logic if two statements have identical truth tables, they are logically equivalent; bitwise and and logical && have identical truth tables. Same goes for all bitwise and boolean unary and binary functionsHullaballoonatic
12/03/2019, 9:50 PMHullaballoonatic
12/03/2019, 9:50 PMxor.Hullaballoonatic
12/03/2019, 9:50 PMBoolean::xor?Hullaballoonatic
12/03/2019, 9:51 PMHullaballoonatic
12/03/2019, 9:51 PMHullaballoonatic
12/03/2019, 9:52 PMand and or are exclusive to bitwise operationsHullaballoonatic
12/03/2019, 9:56 PMHullaballoonatic
12/03/2019, 9:59 PMHullaballoonatic
12/03/2019, 10:00 PMHullaballoonatic
12/03/2019, 10:02 PMBoolean would just extend Number and be comparable to other `Number`s.Hullaballoonatic
12/03/2019, 10:03 PM=== vs == distinction is in kotlin. I initially assumed === meant equal hashcodes or that they must be the same javaclass, and that == was using compareTo operator, but that is not the case.streetsofboston
12/03/2019, 10:04 PM=== compares the instance reference.streetsofboston
12/03/2019, 10:04 PM== executes the equals methodHullaballoonatic
12/03/2019, 10:05 PMoperator compareTo to compare equivalency between 2 instances is to do x.compareTo(y) == 0? That's pretty sillystreetsofboston
12/03/2019, 10:05 PM== and === are the samestreetsofboston
12/03/2019, 10:06 PM== should suffice for equivalency.Hullaballoonatic
12/03/2019, 10:06 PMwhen(myLong) {
0 -> ... // type mismatch Int/Long
1 -> ... // type mismatch Int/Long
else -> ...
}streetsofboston
12/03/2019, 10:07 PMequals takes an Any? as input parameter….Hullaballoonatic
12/03/2019, 10:07 PMstreetsofboston
12/03/2019, 10:08 PMwhen clause by the compiler…. Wonder if the Number#equals enforces the receiver and the input parameter to be of the same class.streetsofboston
12/03/2019, 10:09 PMHullaballoonatic
12/03/2019, 10:09 PMstreetsofboston
12/03/2019, 10:12 PMmyLong == 0 , which won’t compile with myLong.equals(0), which does compile, but still complainsstreetsofboston
12/03/2019, 10:15 PMequals is implemented for a java.lang.Long:
public boolean equals(Object obj) {
if (obj instanceof Long) {
return value == ((Long)obj).longValue();
}
return false;
}streetsofboston
12/03/2019, 10:15 PMLong, it will return false. Since it will always be false, myLong == myInt will not compile, since it always will return false …Hullaballoonatic
12/04/2019, 5:22 PMChar is a Number in Kotlinstreetsofboston
12/04/2019, 5:23 PMpublic class Char private constructor() : Comparable<Char>Hullaballoonatic
12/04/2019, 5:23 PMHullaballoonatic
12/04/2019, 5:23 PMtoCharHullaballoonatic
12/04/2019, 5:23 PM