Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala package object vs Predef

Tags:

scala

predef

What's the difference between something being defined in the scala package object and in Predef?

Is Predef just a relic from pre-2.8 when package objects didn't exist, or is there some other reason why we need both?

like image 733
Luigi Plinge Avatar asked Apr 13 '12 18:04

Luigi Plinge


1 Answers

According to the ScalaDoc,

"The Predef object provides definitions that are accessible in all Scala compilation units without explicit qualification"

So, it is not a package object itself, but acts as one in terms of providing functionality to "all Scala compilation units"

As for why the situation exists, I think you are right, looks to be a legacy issue

As for why it persists, there may continue to be limitations of package objects that prevent PreDef from being merged.

like image 165
virtualeyes Avatar answered Sep 27 '22 00:09

virtualeyes