I know that different functions can have the same name but take different parameters. For instance, the truffle assert library has equalities and inequalities on lots of datatypes. But I just tried to do the same for a constructor and got a compiler complaint. I'd like to be able to say

contract Foo { function Foo (uint onearg) { return Foo(onearg, 2); } function Foo (uint onearg, uint secondarg) { ... do the real work ... } }

1 Answer 1


No, from the docs, "A constructor is optional. Only one constructor is allowed, and this means overloading is not supported."

  • Thanks. I looked for that, and failed. Unfortunate. I wonder if there are plans to allow it. Feb 27, 2018 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.