2

while designing my contracts, I'm wondering if its better to use a struct, and then one mapping that holds that struct type as the value. Or use a bunch of different individual mappings and no struct? In terms of 'better' I guess just general Solidity standards and gas wise.

I read this question's answer: What is better, mapping a struct with 2 variables or having 2 mappings?

And the user chose to use the solution that cost more gas because it was cleaner. Is this the correct choice? In my situation I'd be storing about 8 variables in the struct, or have 8 different mappings.

Thanks!

  • @niksmac I pointed out I read that answer and questioned why the user chose the solution that costs more gas ? Is it proper Solidity standards to use the struct over mappings? – savard Apr 5 '18 at 6:40
  • I think it depends which is the best. What is the best for your usecase? It's a question of how you design your code. Solidity is a very new language and there aren't standards set for everything. TLDR; You can use either one – Daniel Luca CleanUnicorn Apr 6 '18 at 15:35
  • @cleanunicorn ok, that makes sense, thanks for the response ! – savard Apr 7 '18 at 4:39