DEV Community

Discussion on: why kotlin complie wrong code?

Collapse
 
unthrottled profile image
Alex Simons

The code is valid, however the IDE is telling you that what is written isn't going to work. See how age is highlighted and there is a recursion icon in the gutter. When you hover over age you get Recursive property accessor

The compiler is there to help you with any syntax mistakes, its job isn't to help you with the semantics of your code. That's where the IDE can help you. It can tell you that the code you wrote isn't going to work.