KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Following is a Scala class with constructors. My questions are marked with **** class Constructors( a:Int, b:Int ) { def this() = { this(4,5) val s : String = "I want to dance after calling constructor" //**** Constructors does not take parameters error? What is this compile error? this(4,5) } def this(a:Int, b:Int, c:Int) = { //called constructor's definition must precede calling constructor's definition this(5) } def this(d:Int) // **** no equal to works? def this(d:Int) = //that means you can have a constructor procedure and not a function { this() } //A private constructor private def this(a:String) = this(1) //**** What does this mean? private[this] def this(a:Boolean) = this("true") //Constructors does not return anything, not even Unit (read void) def this(a:Double):Unit = this(10,20,30) } Could you please answer my questions in the **** above? For example Constructors does not take parameters error? What is this compile error?
Tags (comma-separated)
Save Edits
Cancel