在Address Payment[]存储引用中根据参数查找后找不到或看不到成员&push" [英] Member "push" not found or not visible after argument-dependent lookup in address payable[] storage ref

查看:13
本文介绍了在Address Payment[]存储引用中根据参数查找后找不到或看不到成员&push"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

players.push(msg.sender);语句中,我收到以下错误:

在Address Payment[]存储参考中根据参数查找后找不到或看不到成员&push&q;

因此,我无法推送到Solidity中的Payment数组。这里有什么解决办法?

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0;

contract Lottery {
    address public manager;
    address payable[] public players;

    constructor() {
        manager = msg.sender;
    }

    function enter() public payable {
        players.push(msg.sender);            // ERROR IN THIS LINE
    }
}

推荐答案

如果您使用Solidity0.7进行编译,则一切正常。

此错误显示为实度0.8,这是因为在0.8中msg.sender不再自动。因此,您需要首先将其设置为payable

players.push(payable(msg.sender));

这篇关于在Address Payment[]存储引用中根据参数查找后找不到或看不到成员&push"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆