Kotlin Usability
Note this blog post contains my notes from the Usability section of the book Atomic Kotlin. Consider buying a copy of the book for a more detailed reference. Extension Functions Extension functions add member functions to existing classes The receiver is the type you extend Example defining an extension function package extensionfunctions import atomictest.eq fun String.singleQuote() = "'$this'" fun String.doubleQuote() = "\"$this\"" fun main() { "Hi".singleQuote() eq "'Hi'" "Hi".doubleQuote() eq "\"Hi\"" } You call extension functions as if they were members of the class