为什么不可调用?
Why is no callable?
在 0.5.0 版本中练习 Solidity。我是初学者。
我在网上看到是通病,但是没找到原因,
最奇怪的是,我见过有人说同样的代码没有给出错误,而其他人却给出了错误。我什么都不清楚。
pragma solidity ^0.5.0;
contract Variables {
string public one = "One";
int public two = -2;
uint public tree = 3;
address public myaddress = msg.sender;
mapping(address => estructura) map;
struct estructura {
uint four;
uint five;
}
function setestructura(uint a, uint b) public {
map(myaddress).four = a;
map(myaddress).five = b;
}
}
函数中的错误是:
Type is not callabe
和 TypeError: member "four" is missing or not visible after argument-dependent search in tuple ()
您可以通过替换
来修复它
map(myaddress).four = a;
map(myaddress).five = b;
至
map[myaddress].four = a;
map[myaddress].five = b;
在 0.5.0 版本中练习 Solidity。我是初学者。
我在网上看到是通病,但是没找到原因, 最奇怪的是,我见过有人说同样的代码没有给出错误,而其他人却给出了错误。我什么都不清楚。
pragma solidity ^0.5.0;
contract Variables {
string public one = "One";
int public two = -2;
uint public tree = 3;
address public myaddress = msg.sender;
mapping(address => estructura) map;
struct estructura {
uint four;
uint five;
}
function setestructura(uint a, uint b) public {
map(myaddress).four = a;
map(myaddress).five = b;
}
}
函数中的错误是:
Type is not callabe
和 TypeError: member "four" is missing or not visible after argument-dependent search in tuple ()
您可以通过替换
来修复它map(myaddress).four = a;
map(myaddress).five = b;
至
map[myaddress].four = a;
map[myaddress].five = b;