Is it not possible to write: “result.plus(if (condition) 1f else 0f)” in kotlin?
Summary This incident revolves around a subtle Kotlin behavior: plus() does not mutate the original value, while += does. A junior engineer assumed both expressions were equivalent, leading to incorrect numerical results in production code. Root Cause The failure stems from a misunderstanding of Kotlin’s immutability model for primitive wrappers and numeric operations. Key points: … Read more