How do we make a call to a private primary constructor in scala?
Answer / Kumar Gaurav
In Scala, you cannot directly call a private primary constructor. You should create an object companion that defines the application's entry point and use it instead.nExample:n```scalanclass MyClass private(val data: Int)nobject MyClass{n def apply(data: Int): MyClass = new MyClass(data)n}nMyClass(10)n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Is Scala Statically-Typed Language?
What is 'Type Inference' in Scala?
Explain que with example?
Popular clients who are using Play and Scala to develop their applications?
What is the default Unit and Functional Testing Framework for Play? What is the default Build Tool for Play? What is the Default Template Engine for Play? What is the built-in Web Server available in Play Framework?
How can you format a string?
What does sortedset in scala collection?
List the advantages of using scala over other functional programming languages.
What square measure the Scala variables?
What is a companion object in scala?
What is traversable in scala collection?
What is the utilization of tuples in scala?