Complete the code to safely cast 'obj' to String using 'as?'.
val str = obj [1] StringThe safe cast operator as? tries to cast the object and returns null if it fails, avoiding exceptions.
Complete the code to safely cast 'item' to Int and assign to 'number'.
val number: Int? = item [1] IntUsing as? safely casts 'item' to Int or returns null if it cannot be cast.
Fix the error in the code by replacing the cast operator with a safe cast.
val text = data [1] StringReplacing as with as? prevents exceptions by returning null if the cast fails.
Fill both blanks to create a safe cast and check if the result is null.
val result = value [1] String if (result [2] null) { println("Cast succeeded") }
Use as? for safe cast and != to check if the cast did not return null.
Fill all three blanks to safely cast 'input' to Double, check if not null, and print the value.
val number = input [1] Double if (number [2] null) { println("Number is: [3]") }
Use as? for safe cast, != to check not null, and print the variable number.