I guess I puted my question the wrong way lets say...
# getting-started
m
I guess I puted my question the wrong way lets say I have class that have some fields and methods and inside it I have a companion object that need to access the fields and methods of the outer class
w
mohamed.hajr: You can’t do that
object is a singleton, and it doesn’t actually live within enclosing class
You’d either need to have outer object instead of a class, or
inner class
instead of a static object
Or pass instance of your object to methods/whatever used in your companion object
m
What am trying to do is I want only the things in the companion object is the ones to be accessible by other classes but however all the other fields and methods in the outer class only the companion could use them does that make sense ?
w
Why wouldn’t having only some fields
public
and the rest
private
?
m
Cause the outer class methods and fields those are private ones no body should access them or modify them
and I have some other fields and methods that you can interact with the class using them
but I want them to be singltons
and access them via the class name like static methods in java
w
Then it seems like the outer class should be an
object
too
m
So just on object which is the outer class and no any companion objects
yeah that handled it thanks a lot dude really appreciate it