I am fairly new to Solidity and at this point, reviewing contracts that are active and on chain. I am trying to understand every detail. This withdraw function has got me stumped.
function withdraw(address token, uint256 amount) external onlyOwner {
if(token == address(0)) {
payable(_msgSender()).transfer(amount);
} else {
IERC20(token).transfer(_msgSender(), amount);
}
}
Particularly the two parts that are "if(token == address(0))" and "payable(_msgSender()).transfer(amount);". The best explanation for address(0) is here What is address(0) in Solidity but I have to admit, both answers have me bewildered. I have read that payable() is casting the address to be payable and that this has been deprecated. Just looking for a short explanation as if to a child.
A decent amount of time searching to no avail.