Home > Back-end >  simple string memory question in solidity
simple string memory question in solidity

Time:07-21

my question is simple. in first example of the image Remix asks me to insert memory, when I insert it it says it shouldn't be there. I am so confused. Am I not even understanding what the error is? Thanks

CodePudding user response:

sorry brother my commenting feature is not eligible yet. I wanna say, bro pls share your code snippet. It looks like there is something else wrong, Remix should not give that first warning and it's right about the second warning. Maybe it's a bug in remix etc. I tried the same code and it compiled successfully. Refresh your pc and clear your browser's cache.... And also try this mapping(unit => string) private nomToRom; Mayve by being more specific, Remix don't get mad xD

CodePudding user response:

The first error is because in local variables (inside functions), when it comes to structures, assignments or arrays, you have to explicitly declare the location of the data (memory, storage, call data), you can find more information about this in the documentation: https://docs.soliditylang.org/en/latest/types.html?highlight=data location#data-location

Said this, check out this previous question and its answer: How to interact with mapping of mappings for structs in solidity?

  • Related