bearing in mind all those functions are persistent...
# announcements
g
bearing in mind all those functions are persistent (ie local factories), can you not write a simple
asIterable()
extension function on your external class?
p
Won’t that create a new object? What’s nice about the extension functions is that they don't
g
an
iterable
object gets allocated every time you write a for-each loop, and even with the most abusive kotlin code you can write I still suspect you wont hit the JVM as hard as a run-of-the-mill scala program. I think your committing an act of premature-optimization if your worried about an
asIterable
extension method that allocates the few dozen bytes needed for an Iterable instance thrashing the GC.
but, specifically what you might be talking about is type classes or what Cedric called "Extension Types"