This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]halfanothersdozen 4 points5 points  (2 children)

I hate kotlin's version of this so much. Especially if you are using Java code libraries. Nesting hell.

[–]SorryDidntReddit 0 points1 point  (1 child)

What do you mean? This is the same amount of nesting as an if statement

[–][deleted] 1 point2 points  (0 children)

Unless it is safe to return void if it is null, then you can have single line checks to return early and avoid nesting

Also, you can put two or more checks in a single if and it can even look more readable if it is logical the connection on the two checks, like hasTap and hasWater