Created
April 20, 2022 19:12
-
-
Save PatrickAlphaC/3e936cb84ce72ac2964d93b44b3366a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.12; | |
contract StringConcater { | |
// only in 0.8.12 and above | |
function concatStringsNewWay() public pure returns(string memory){ | |
string memory hiMom = "Hi Mom, "; | |
string memory missYou = "miss you."; | |
return string.concat(hiMom, missYou); | |
} | |
function concatStringsOldWay() public pure returns (string memory){ | |
string memory hiMom = "Hi Mom, "; | |
string memory missYou = "miss you."; | |
return string(abi.encodePacked(hiMom, missYou)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment