N26 Dec 5, 2018

Mastering Kotlin Conventions: Operators and Arithmetic Operations

Article Summary

Gopinath Langote from N26 shows how Kotlin's operator overloading turns verbose code like Number(1).plus(Number(2)) into elegant Number(1) + Number(2). This isn't just syntactic sugar—it's a fundamental shift in how we write expressive Android code.

This practical guide from N26's engineering team breaks down Kotlin's operator conventions using a real-world Money class example. The article demonstrates how the operator keyword transforms standard functions into intuitive mathematical operators, making code more readable and maintainable.

Key Takeaways

Critical Insight

Kotlin conventions let you replace verbose function calls with intuitive operators by adding a single operator keyword to extension functions.

The article hints at additional arithmetic conventions like plusAssign and unaryPlus, with a promised Part II covering even more operator patterns.

Recent from N26

Related Articles