I think conversation would be much more easier if Kotlin would use the keywords implicit and explicit like C#, it would first make converting numeric values less painful than using the .toType() functions.
It would also make creating new numeric classes easier, even old ones like BigDecimal.
1 Like
Kotlin hates implicit, so this is not going to happen.
First, it’s hard to understand if not used correctly:
and second there is a technical issue:
https://kotlinlang.org/docs/reference/basic-types.html#explicit-conversions
4 Likes
Also agreed to add the implicit
and explicit
keywords, especially cooperating with the operator
keyword. In C#, an implicit keyword is used to declare an implicit user-defined type conversion operator, in other words, this gives the power to your C# class, which can accepts any reasonably convertible data type without type casting.