Can anyone tell why my get() function only returns the string "name" in Remix? I'd like it to return all the values within the users mapping like i've defined, can you help me accomplish this?

pragma solidity ^0.5.0;

contract Profile {

    struct User {
       string name;
       string subtitle;
       string sdescription;
       string ldescription;
       string weburl;
       string memehash;

    mapping(address => User) public users; 

  function set(string memory _name, string memory _subtitle, string memory _sdescription,string memory _ldescription, string memory _weburl, string memory _memehash) public {
    users[msg.sender] = User(_name, _subtitle, _sdescription, _ldescription, _weburl, _memehash);

  function get() public view returns (string memory) {
    return users[msg.sender].name;
    return users[msg.sender].subtitle;
    return users[msg.sender].sdescription;
    return users[msg.sender].ldescription;
    return users[msg.sender].weburl;
    return users[msg.sender].memehash;

get needs to return all strings in mapping

"test" is the name i set in Remix with the set() function. ^

1 Answer 1


Because that's not how multiple return is working in Solidity. In almost every programming language whenever a method reaches first return line then everything below is ignored. Just change your function to this and it should be ok:

function get() public view returns (string memory, string memory, string memory, string memory, string memory, string memory) {
    return (

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.