mbonnin
01/08/2019, 2:29 PMList listOfDouble = CollectionsKt.listOf(1.0D);
if (listOfDouble == null) {
throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.List<kotlin.Int>");
} else {
int first = ((Number)listOfDouble.get(0)).intValue();
System.out.println("first=" + first + " (" + Integer.TYPE.getName() + ')');
}phldavies
01/08/2019, 2:31 PMmbonnin
01/08/2019, 2:31 PMmbonnin
01/08/2019, 2:32 PMmbonnin
01/08/2019, 2:32 PMphldavies
01/08/2019, 2:33 PMInteger to int but through a cast to the Number superclass to invoke the intValue() method. Because of this it's actually casting the boxed Double value to Number (which succeeds) instead of the expected cast of the Double to Integer which would failDico
01/08/2019, 11:24 PMDico
01/08/2019, 11:24 PMmbonnin
01/09/2019, 8:36 AMDico
01/09/2019, 8:38 AM