Top "Companion-object" questions

In Scala and Kotlin, an object with the same name as a class, used to hold utility members for the class

Access application context in companion object in kotlin

How can we access application context inside companion object in Android kotlin? I have a companion object inside an abstract …

android kotlin companion-object
What is the rationale behind having companion objects in Scala?

Is there a case where a companion object (singleton) for a class is needed? Why would I want to create …

oop scala companion-object
How does Scala's apply() method magic work?

In Scala, if I define a method called apply in a class or a top-level object, that method will be …

scala syntactic-sugar magic-methods companion-object
Kotlin: Difference between object and companion object in a class

What is the difference between an object and a companion object in a class in kotlin? Example: class MyClass { object …

object kotlin companion-object
Android/Kotlin: Error: "Expecting a top level declaration > Task :app:buildInfoGeneratorDebug"

I try to write a class to manage a SQLite DB, but I have the error message "Expecting a top …

android sqlite kotlin companion-object
Access methods outside companion object - Kotlin

I'm pretty new to kotlin and I was wondering if it's possible, and if it's against best practice to access …

kotlin companion-object
how to access companion object from object instance in kotlin?

Simple sample class with companion object class MyClass { companion object { val test = 25 } } The value test can be accessed from by …

kotlin companion-object
classifier does not have a companion object

i want to use BottomNavigationView in my app and i'm facing this problem with kotlin (never had it before with …

android-studio kotlin fragment companion-object
Kotlin - Is it possible to initialize companion object before the init block in a class?

Is it possible to initialize an companion object before the init block in a Kotlin class? If so, how? If …

oop static kotlin companion-object static-initializer
How to implement a counter in functional programming way

While trying to understand companion objects, I have written following code which counts the number of times a class was …

scala functional-programming companion-object