In this code here, does theRun() function act as a constructor?
contract theRun {
address private admin;
function theRun() {
admin = msg.sender;
}
}
Are you sure that compiler is not giving you any error? Because you haven't mentioned scope in your theRun()
.
And no, the theRun()
won't act as constructor.
Depending on your version, Since solidity 0.4.23
, constructors needs to be specified using the constructor
keyword, constructors are optional.
So you can declare your constructor using a function with the same name as your contract, IF you’re using a version older than 0.4.23
No it doesn't.
The most and obvious reason is that a function can never have the same name as the contract.