Reputation: 165
I have a number of different scala files each defining their own class. All of the files are located in the SAME directory. It is my understanding that if they are in the same directory you should not need to worry about packages or imports. However I am trying to compile a file and I'm receiving not found
errors.
Is there a difference between using classes and objects from different files and can someone explain how to do it?
Upvotes: 2
Views: 2637
Reputation: 10894
Check if your files all in the same package
.
Scala breaks with the Java convention that the folder structure needs to represent the package structure. So you will get no feedback and or automatic warning when you have file in the wrong package.
In given example the files are located in the same folder but belong to different packages.
src/main/scala/biz/neumann/foo.scala
package biz.neumann.not_in_example
class Foo
src/main/scala/biz/neumann/bar.scala
package biz.neumann.example
class Bar
biz .neumann .not_in_example .Foo
.example .Bar
Upvotes: 6