How do we declare a private Primary Constructor in Scala? How do we make a call to a private Primary Constructor in Scala?
Answer Posted / Mohd Junaid Siddiqui
To declare a private primary constructor, you simply add the 'private' keyword before 'def'. To call a private primary constructor from another constructor (secondary constructor), use the 'super' keyword. Here is an example: class MyClass(private def this(name: String)) { ... }
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers