Timeline for How to update an array of struct?
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Jun 20, 2022 at 5:37 | history | edited | Ismael♦ | CC BY-SA 4.0 |
did you mean => instead of ->
|
S Jun 20, 2022 at 5:37 | history | suggested | Giorgi Gvimradze | CC BY-SA 4.0 |
did you mean => instead of ->
|
Jun 19, 2022 at 0:52 | review | Suggested edits | |||
S Jun 20, 2022 at 5:37 | |||||
Feb 28, 2022 at 21:01 | comment | added | Hristo Todorov | It is cheaper because if you want only the index you can get rid of the address which take bock space which lead to bigger cost | |
Feb 28, 2022 at 20:59 | comment | added | Hristo Todorov | Yes you are correct. This can be bypassed if shift all of the recors by one which is easily done if instead of initialising the array as empty to have one stored item in it. | |
Feb 25, 2022 at 17:59 | comment | added | jriver27 |
What happens when the updateEntityArray method is called with an address that is not in the addressesEntityIndex? Wouldn't that return 0 and therefor update the wrong item in the array?
|
|
Feb 24, 2022 at 22:22 | comment | added | jriver27 | @HristoTodorov You mentioned that it's more expensive. Why is that? | |
Oct 28, 2021 at 6:34 | comment | added | anthony422 | i did but dont have enough reps :D once i do it'll appear | |
Oct 27, 2021 at 15:00 | comment | added | Hristo Todorov | you are welcome. dont forget to upvote :) | |
Oct 27, 2021 at 14:52 | vote | accept | anthony422 | ||
Oct 27, 2021 at 14:52 | comment | added | anthony422 | ohhh, very true! i forgot about the refference and copy between storage and memory. thanks alot for the answer! | |
Oct 27, 2021 at 7:27 | comment | added | Hristo Todorov |
Yes, but if you declared it in memory the moment you addit to the entityArray (entityArray.push(newEntity); ) it will be added in the storage and now you have it once in memory and once in storage where as if you declared directly to storage you omit the memory declaration.
|
|
Oct 27, 2021 at 6:42 | comment | added | anthony422 | looks good, but when u declared "newEntity" why did u put it in storage? if you make it Entity memory newEntity = Entity(msg.sender, _data); it would be much cheaper | |
Oct 26, 2021 at 10:17 | history | answered | Hristo Todorov | CC BY-SA 4.0 |