79172476

Date: 2024-11-09 09:46:10
Score: 1
Natty:
Report link

These are not the same thing, because Kotlin is statically typed language.

In the first case, you declare the variable result as Int, because x*2 is of Int type, as far as x is of Int type. And later try to assign a String value to it. Of course, this causes a type mismatch exception.

In the second case, you declare the variable as String from the very beginning, and assign a String to it latet. Everything is fine here. No error occurs.

Reasons:
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: iramm