Aren`t constructors used to initialize variable at the time of contract creation? In common patterns section in solidity documentation, payable constructor is used for withdrawal pattern example.
constructor() payable {
richest = msg.sender;
mostSent = msg.value;
}
What is the significance of this cant we hard code the value or initialize it with some other function?
function deposit() payable {..}. But there are usecases where you need this. Example could be an unidirectional payment channel, where you put some ether in escrow on the channel instantiation. – ivicaa Mar 01 '18 at 11:01