What is the use of PreDef in Scala?

This is for Scala, Python, core Java, java script, Struts, Jsp, Servlet, Spring, EJB etc. Programming Language and Framework
forum_admin
Site Admin
Posts: 186
Joined: Wed Jul 16, 2014 9:22 pm
Contact:

What is the use of PreDef in Scala?

Postby forum_admin » Tue Dec 19, 2017 4:49 am

What is the use of PreDef in Scala?


forum_admin
Site Admin
Posts: 186
Joined: Wed Jul 16, 2014 9:22 pm
Contact:

Re: What is the use of PreDef in Scala?

Postby forum_admin » Tue Dec 19, 2017 4:52 am

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

- defined in scala package as “scala.PreDef”. It is an utility object.

It defines many utility methods as shown below:

Console IO (print,println etc)
Collection utility methods
String utility methods
Implicit conversion methods
Assertion utility methods etc.

For instance, print, println, readLine, readInt, require etc methods are defined in PreDef object.

PreDef is available to use its methods without importing in all Scala Programs because Scala Compiler imports this object into all compilation units like Class, Object, Trait automatically.

https://www.journaldev.com/8958/scala-i ... ns-answers


Return to “Core Java, Scala, Python and Advanced Programming or development”

Who is online

Users browsing this forum: No registered users and 3 guests