Scala package object vs Predef

What is the difference between what is defined in the scala package object and in Predef ?

Is Predef relic from pre-2.8 when package objects did not exist, or is there some other reason we need both?

+6
source share
1 answer

According to ScalaDoc,

"The Predef object provides definitions that are available in all Scala compilation units without explicit qualifications."

Thus, this is not the package object itself, but acts as one of the possibilities of providing functionality to all "Scala compilation units"

Regarding the situation, I think you're right, it looks like an obsolete problem

As to why it is stored, there may be restrictions on package objects that prevent PreDef from merging.

+4
source

Source: https://habr.com/ru/post/913155/


All Articles