Kotlin as vs as? : unsafe and safe cast operator (class cast exception)
1. Kotlin cast operator You can use 'as' to apply type casting. However, if the type can not be assigned to the specific target data, it receives the ClassCastException. If you want to remove the exception, you should use 'as?' instead of the 'as' operator. This operator returns 'null' if the class cast exception occurs. 2. Unsafe operator 'as' The operator 'as' can not assign data to unrelated ..
2022.05.29