I have a question after reading the <coding conve...
# codingconventions
v
I have a question after reading the coding conventions. It says to not separate extension methods from regular methods. So should I take that to mean that private extension methods should be within the class that makes use of them? I assume this would also apply to properties? For instance:
Copy code
class A {
    fun doSomething(): Unit {
        ...
    }

    private val B.things: List<Thing>
        get() = ...

    private fun C.helpMe(): Thing { ... }
}
I currently have the extensions at the top-level, but from reading the guidance it sounds like I should move them into the class itself.
r
note that, to call such a function you would have to do
Copy code
with (A()) {
    C().helpMe()
}
eg, instance of
A
has to be one of
this
-es, and instance of
C
either in
this
-es or before dot which, while sometimes useful, is usually not what you want, and notably it's different from extension methods being on top-level
v
Yes, these are not general purpose extensions. They are strictly used to help simplify the work that A does.