Import from singleton object?


#1

It seems like this would be useful. Any plans to do it? Similar to Scala, I'd like to be able to call functions from a singleton without the prefix.

object Thing {
  fun foo(x: Int) { }
}

import Thing.foo

foo(123)

Is there a different way to do this in Kotlin?

Rob


#2

You could define your functions outside the object AKA package level functions

In that case you just import the package with * and that’s all

import com.mycompany.util.*

foo(123)


#3

That's probably all I need. +1 for simplicity.

Rob