If I have a package com.example, I can create a class in that package like this:
package com.example {
class MyClass
}
or like this:
package com {
package object example {
class MyClass
}
}
In both cases, the resulting class is (as far as other Scala code is concerned, at least) com.example.MyClass.
There are certainly incidental differences. In the first instance, the resulting compiled class is com/example/MyClass.class whereas in the second it's com/example/package$MyClass.class but are there any substantive differences?
The difference in generated class file names was discussed on scala-internals, and hopefully will disappear in Scala 2.10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With