-
-
Save davidhq/4fbc8c6fb7c4513684ba9e542cddd4f6 to your computer and use it in GitHub Desktop.
This file contains 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