mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
26 lines
426 B
Solidity
26 lines
426 B
Solidity
struct Struct { uint x; }
|
|
|
|
library L {
|
|
function f(Struct storage _x) internal view returns (uint256) {
|
|
return _x.x;
|
|
}
|
|
}
|
|
|
|
contract C {
|
|
using L for Struct;
|
|
|
|
Struct s;
|
|
|
|
function h(Struct storage _s) internal view returns (uint) {
|
|
// _s is pointer
|
|
return _s.f();
|
|
}
|
|
function g() public returns (uint, uint) {
|
|
s.x = 7;
|
|
// s is reference
|
|
return (s.f(), h(s));
|
|
}
|
|
}
|
|
// ----
|
|
// g() -> 7, 7
|