WTF-Solidity icon indicating copy to clipboard operation
WTF-Solidity copied to clipboard

第20章的一个测试题有问题

Open LIYANG-UST opened this issue 2 years ago • 2 comments

image 正确的方式应该是这样?

constructor(uint256 _amount) payable {
    payable(address(this)).transfer(_amount);
}

LIYANG-UST avatar Nov 24 '22 07:11 LIYANG-UST

你写的跟选项有什么不一样

AmazingAng avatar Nov 24 '22 08:11 AmazingAng

需要把address(this)转成payable才能使用send和transfer吧

LIYANG-UST avatar Nov 24 '22 12:11 LIYANG-UST

需要把address(this)转成payable才能使用send和transfer吧

是的 所以这个选项不正确

AmazingAng avatar Dec 21 '22 04:12 AmazingAng