4thSpace
4thSpace

Reputation: 44352

Accessing Class defined inside an Object in Scala

In Scala, I have two files each defining an Object. Both defined in the same package.

When I try to reference ClassA in object2, I get an error that ClassA cannot be found.

What am I doing wrong? If the objects are in the same default namespace, shouldn't they be able to see each other?

Upvotes: 1

Views: 51

Answers (1)

Sami Badawi
Sami Badawi

Reputation: 1032

Have you tried this:

object object2{
    def main(args: Array[String]) {
        val a = new object1.ClassA()
    }
}

Upvotes: 2

Related Questions