if I have a contract which I use to store patient weight. I want to display last 5 weights of that patient. how can I access previous value on weight?


I recommend creating a struct called patient which stores whatever you would like: name, weight, etc. The weight should be an array of uint (I recommend using grams as a scale of weight since you cannot use floats or doubles). Now what you would do is create a mapping with uint => patient. Afterward, you can use the mapping with the uint value of the patient to retrieve the struct, from there you can retrieve their weight array.

| improve this answer | |

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