Overview - Inner class access to outer members
What is it?
In Kotlin, an inner class is a class defined inside another class that can access the outer class's members directly. Unlike a nested class, an inner class holds a reference to its outer class instance. This allows it to use properties and functions of the outer class as if they were its own.
Why it matters
Inner classes help organize code by grouping related functionality together while still allowing access to the outer class's data. Without inner classes, you would need to pass references explicitly or duplicate code, making programs harder to maintain and understand.
Where it fits
Before learning inner classes, you should understand basic classes and nested classes in Kotlin. After mastering inner classes, you can explore advanced topics like anonymous inner classes, lambdas, and object expressions.