How to import a package object?

I can’t speak to Java – I just don’t know it that well – but again, I think you’re focusing way too much on package objects, which are an edge case and mostly irrelevant. (Especially in Scala 3.)

Seriously: while you’re learning the language, I recommend mostly ignoring package objects. They aren’t used much in normal code – they were introduced in Scala 2 to make certain usages more convenient, and they’re basically dead in Scala 3, since we don’t need them any more.

Java is a very different language: I think you’d have to ask Java folks why it works there. I believe it fails in Scala because you’re setting up ambiguity; I don’t know why Java would tolerate that.

1 Like