Why is the function `List(7) { it + 3 }` a top lev...
# stdlib
h
Why is the function
List(7) { it + 3 }
a top level function instead of an static invoke operator? Is the latter somehow unintended usage of the language, or against standard code style? static invoke operator is just so much more efficient than constructors, given you can error check prior to instantiation, among many other things. I can see how it can read very alien to those not kotlin-savvy, however.
j
> static invoke operator is just so much more efficient than constructors, given you can error check prior to instantiation, among many other things anything you can do in an invoke function you can do in a top-level function. nothing about invoke functions is more efficient.
h
true, i suppose the only reason why I tend to prefer static invoke to top-level is that IDEA formats the former as if it were a constructor, and the latter like a function.
k
I prefer top levels as well, it's a bit less boilerplate if you've just got a couple ones.
1
i
List
interface doesn't have a companion object and introducing it would be tricky.