October 2025
Intermediate to advanced
100 pages
2h 27m
English
The person who wrote this program has forgotten about Kotlin’s operator precedence rules, and the oversight has resulted in a bug. We can guess that the goal is to take the bonus value and add the salary to it—with 0 acting as a fallback option that would only be used if bonus was null.

That interpretation is backed up by the names of the variables as well as by your intuitive left-to-right reading of the program, which can make the bug hard to spot. But that’s not how Kotlin interprets this code. In reality, 0 + salary is grouped together and evaluated first.
Thanks to that unintended grouping, the overall result is just the value ...
Read now
Unlock full access