mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
19 lines
352 B
Solidity
19 lines
352 B
Solidity
library L {
|
|
function at(string memory a, uint i) internal pure returns (uint8) {
|
|
return uint8(bytes(a)[i]);
|
|
}
|
|
}
|
|
|
|
contract C {
|
|
using L for string;
|
|
|
|
function secondChar() public returns (uint8) {
|
|
string memory input = "abc";
|
|
return input.at(1);
|
|
}
|
|
}
|
|
// ====
|
|
// compileViaYul: also
|
|
// ----
|
|
// secondChar() -> 98
|