Hi all, I'm learning Kotlin through koans and I sa...
# getting-started
i
Hi all, I'm learning Kotlin through koans and I saw this code (not my, part of the exercise). The code is here: https://pastebin.com/A7vwUqiy I don't understand why the extension method set (at the bottom of the snippet) was written as an extension method? why not just write it as a normal method inside the Tag class? Is this just more idiomatic in Kotlin, or do you achieve something here that cannot be achieved with normal methods?
d
One could argue that
set
is part of the DSL and if you put it in a different package then you have isolated the DSL related methods from the class itself
i
Ok, thanks for info 👍 So it doesn't make sanse to have it like this in the same file, but rather having it totally separated from the class itslef
r
Sometimes it does. Check out @elizarov's article about extension-oriented design: https://medium.com/@elizarov/extension-oriented-design-13f4f27deaee
i
Thanks, will do