2

I need some help. I just cannot figure out how to add data (here more animals with values) to a List like following:

List animal = [{ "display": "Dog", "value": "1",},{"display": "Cat","value": "2",}];

-> so the structure of a entry must be like {"display" : "XYZ", "value": "NRXYZ"}. Is there a function to dynamically add more animals with values.

Thanks a lot!

0

1 Answer 1

3

You can use add() method:

animal.add({"display" : "XYZ", "value": "NRXYZ"});

If you want to add multiple animals at the end of the list you can use addAll() method:

animal.addAll([{ "display": "Ferret", "value": "3",}, {"display": "Bird", "value": "4",}]);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank‘s a lot! I‘ve already tried it this way but apparently i did something wrong. Howewer, now it‘s working! :-)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.