DEV Community

sot528
sot528

Posted on

Ethereum:New Solidity constructor

Since Solidity v0.4.23, Solidity has new constructor notation.

And The old one was deprecated.

Old

pragma solidity 0.4.23; contract Foo { function Foo() public { // ... } } 
Enter fullscreen mode Exit fullscreen mode

New

pragma solidity 0.4.23; contract Foo { constructor() public { // ... } } 
Enter fullscreen mode Exit fullscreen mode

Note

The old one raise below.

Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. 
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
guardadodev profile image
Guardadodev

Quick and very well explained, Thanks!

Collapse
 
sot528 profile image
sot528

😉