I have seen two ways to assign the creator of the contract. The first way is this way which you don't put the assignment in the constructor function.
pragma solidity ^0.6.6;
contract Test {
address creator = msg.sender;
constructor() public {}
}
The second way is when you assign the creator inside the constructor function
pragma solidity ^0.6.6;
contract Test {
constructor() public {
address creator = msg.sender;
}
}
Is there any difference between these two? which one is better? and why?
EDIT : i wrote the second code in a totally wrong way. i meant this code
pragma solidity ^0.6.6;
contract Test {
address creator;
constructor() public{
creator = msg.sender;
}
}