Toddobryan
11/02/2019, 2:03 AMAny? instead of Number?
fun String.toNumber(): Number? = toIntOrNull() ?: toLongOrNull() ?: toBigIntegerOrNull()Mike
11/02/2019, 2:19 AMHullaballoonatic
11/02/2019, 8:42 PMInt, Long inheriting from kotlin's Number, which does not inherit from java's, which BigInteger does.Hullaballoonatic
11/02/2019, 8:42 PMBigInteger("123") is Number resolves to true, and I have no idea why that isToddobryan
11/02/2019, 8:55 PMas Number? after toLongOrNull(). (Not after toBigIntegerOrNull() as you might expect.)vs.thaakur
11/04/2019, 5:25 AMvs.thaakur
11/04/2019, 5:27 AMToddobryan
11/05/2019, 4:08 AMBigInteger("123") is kotlin.Number returns true. It is a great mystery to me why that is, but it is. See here: https://pl.kotl.in/32qL74dYRMatteo Mirk
11/05/2019, 11:20 AMvs.thaakur
11/05/2019, 4:18 PMToddobryan
11/05/2019, 5:32 PM/**
* You can edit, run, and share this code.
* <http://play.kotlinlang.org|play.kotlinlang.org>
*
*/
import java.math.BigInteger
fun main() {
print(BigInteger("123") is kotlin.Number)
}
This is what that link sends me to. https://pl.kotl.in/32qL74dYR
And it prints true.Matteo Mirk
11/06/2019, 10:47 AM