+ 1
What is difference between When and If-Else in Kotlin??
I didn't clearly understand the difference between if-else statements and when statements in Kotlin. What does they do different? They seemed to do the same thing for me.
3 Antworten
+ 2
when can only have statements, that can only have 1 statement, that returns any value, this will allow you to strictly assign a when statement to a variable.
I think when is only a bit similar to switch.
0
No I was asking about when not while😅 .. while is there but I'm asking for the difference between when and if-else. Maybe you are familiar with switch. In the community course of Kotlin says that when is equivalent to Switch in other languages.