@relizarov ("Roman Elizarov") wrote:
Let me explain the story behind this poll. It recently came up as the Kotlin design question, and it is a great illustration of the tradeoffs in the language design and complexities that come up as different language features interact. /1
with quote tweet:
@relizarov ("Roman Elizarov") wrote:
This is not a trick question, just probing your programmer's intuition. Assume that you have a property that coerces its value in the setter:
var percent: Int = 0
set(value) { field = value.coerceIn(0, 100) }Don't run it! What should this line print?
println(--percent)