KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've defined multiple constructors, with some default argument values in all of them. Looks correct (I can't see any ambiguity), but Scala (2.8) compiler complains: multiple overloaded alternatives of constructor define default arguments Does it mean that I can't define default values for overloaded constructors at all? Let me illustrate the situation (primitivized, of course, but illustrative): class A(subject : Double, factor : Int = 1, doItRight : Boolean = true) { def this (subject : Int, factor : Int = 1, doItRight : Boolean = true) = { this(subject.toDouble , factor, doItRight) } def this (subject : String, factor : Int = 1, doItRight : Boolean = true) = { this(subject.toDouble , factor, doItRight) } def this () = { this(defaultSubject) } }
Tags (comma-separated)
Save Edits
Cancel