Thread
#stdlib
    Hullaballoonatic

    Hullaballoonatic

    2 years ago
    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

    jw

    2 years ago
    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.
    Hullaballoonatic

    Hullaballoonatic

    2 years ago
    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.
    karelpeeters

    karelpeeters

    2 years ago
    I prefer top levels as well, it's a bit less boilerplate if you've just got a couple ones.
    ilya.gorbunov

    ilya.gorbunov

    2 years ago
    List
    interface doesn't have a companion object and introducing it would be tricky.